Results 1 to 4 of 4

Thread: Auto loading images to ASDB file , ImageFX error

  1. #1

    Auto loading images to ASDB file , ImageFX error

    Hi all,

    I'm trying to create a program that autopopulates my asdb file with images , for testing I'm trying to load a bmp image 32x32 .
     procedure TForm1.Button1Click(Sender: TObject);
     PxFm: TPxFm;
     pSize: TPoint;
     Image: TBitmap;
     Dest: TBitmap;
     Tolerance: Integer;
     MaskColor: Cardinal;
     IsMasked: Boolean;
     Stream: TMemoryStream;
     ASDB := TAsdb.Create(Self);
      if (not ASDb.Update()) then
        ShowMessage('Failed opening ASDb archive!');
    // change the following format, if necessary
     PxFm.Format:= COLOR_A8R8G8B8;
     // retreive Texture Size from edit boxes
     PxFm.TextureWidth := 32;
     PxFm.TextureHeight:= 32;
     // retreive Pattern Size from edit boxes
     PxFm.PatternWidth := 32;
     PxFm.PatternHeight:= 32;
     // this variable is used for better readability only
     pSize:= Point(PxFm.PatternWidth, PxFm.PatternHeight);
     // this size can be smaller than pattern size to add padding
     PxFm.VisibleWidth := PxFm.PatternWidth;
     PxFm.VisibleHeight:= PxFm.PatternHeight;
     // retreive mask color and tolerance
     IsMasked:= false;
     MaskColor := Shape1.Brush.Color and $FFFFFF;
     Tolerance:= 15;
     // load the image
     Image:= TBitmap.Create();
     LoadBitmap('0.bmp', Image, ifBMP);
     // update some attributes
     PxFm.PatternCount:= (Image.Width div pSize.X) * (Image.Height div pSize.Y);
     // create destination bitmap
     Dest:= TBitmap.Create();
     TileBitmap(Dest, Image, Point(PxFm.TextureWidth, PxFm.TextureHeight),
      pSize, pSize, IsMasked, MaskColor, Tolerance);
     // create auxiliary stream to write PxFm-formatted image data
     Stream:= TMemoryStream.Create();
     WriteBitmapPxFm(Stream, Dest, PxFm);
     // we don't need destination image anymore
     // position to the beginning of our stream
     Stream.Seek(0, soFromBeginning);
     ASDb.WriteStream('0.image', Stream, recGraphics);
    I get a SIGSEGV at TileBitmap , specifically this one :

     procedure UnmaskAlpha(Dest: TBitmap);
     i, j: Integer;
     pl: PLongword;
     Dest.PixelFormat:= pf32bit;
     for j:= 0 to Dest.Height - 1 do
       pl:= bmp2xlbmp(Dest).Scanline[j];
       for i:= 0 to Dest.Width - 1 do
         pl^:= pl^ or $FF000000;  <--------------------------- here 
    Any idea what is wrong, manually adding this file with the Asphyre Manager , same properties is working fine. But it takes a lot of time to add 259 images....


  2. #2
    Hi all,

    Anyway after sleeping I think I'll just re-write the editor along with the game itself . The part about the TTileData . After searching a bit online , in the old Afterwarp forums , and looking for some other games
    I realized they all use sprite sheets .
    So I will not be adding 100 images individually for the MainMenu for example but I will add a complete SpriteSheet. I will alter my TTileData record to look like this (probably) :
     TTileData = record
       Sheet : String; // sheet name from ASDB archive (menu,level01,level02...etc)
       PatternStart :  Word;  // where my desired image starts
       PatternStop : Word; // where my desired image stops (in case it's animated)
       // AnimSpeed : Single;
    I need to go to work now , but I think this might be a better idea , make the ASDB file easier to manage, and far faster to load then with my current 700 ~ individual images.


  3. #3
    Have you checked the code for Asphyre Manager to see how it works? I bet that with litle work you could change it so it is capable of loading multiple images a once itno ASDB.

    Also it is ture that loading entire sprite sheats would be much faster than loading individual images but that does require you to create entire spritesheat using some other program, which might in the end be even slower and require more work. Not to mention that by using of sprite sheats you need to change entire spritesheat even if you do just a small change to one of your images.

    The reason why ASDB is implemented into Asphyre is that it actually is managed sprite sheat which alows you to load the textures into your game much faster than you would by loading them from individual files.

  4. #4
    Some missing info in your first post.

    - We don't see where UnmaskAlpha() is called from.
    - How is Dest: TBitmap created before sending as parameter?
    - You are typecasting it, so couldn't it be procedure UnmaskAlpha(Dest: bmp2xlbmp);
    - What is bmp2xlbmp anyway?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts