Results 1 to 6 of 6

Thread: ImageList.Add

  1. #1

    ImageList.Add

    Ok I've been fuming over this problem for about 3 hours now, so I figured it was time to swallow my pride and ask in here.

    I'm make a very basic 2d map editor (for a game I'll hopefully get around to) and it's going ok so far, except for one thing.
    When I try:

    ImageList.Add('bitmapfile', nil);

    Only the top row of the bitmap gets saved to the ImageList (I've confirmed by 'watching' the ImageList.Count property).
    The bitmap is 384x128 (tiles are 64x64) and it's getting drawn into a TDrawGrid that's 512x512 (8x8 tiles) square. I have the relevant settings to allow 64x64 tiles in the ImageList and I've also set the AllocBy to 64 so that it can theoretically store the 8x8 tiles required for the largest bitmaps.

    I've also tried the Read/WriteComponentResFile option but that keeps crashing the program.

    I need to add the images in real time because they will need to be rotated and there'll be 4 times the images to save them in all rotations.

    I'd prefer not to use DelphiX (or the like) at the moment since it's only a basic project and I'd like to keep it as simple as I can.
    Why are toasters created with a setting that burns the bread to a crisp no sane person could eat?
    <br />Who said Humpty Dumpty was an egg?
    <br />Why are there no 'B' sized batteries?
    <br />Why don't you ever see baby seagulls?

  2. #2

    ImageList.Add

    Hello.

    If I've understood you correctly, you would like to have a one big bitmap image which would be automatically split by the TImageList during its addition process. As far as I know, that is not possible. TImageList works in an opposite way. It merges all added bitmaps into one big bitmap not visible for us. So you have two choices:
    - split your big bitmap into the tiles which you want and add them one by one into TImageList.
    - write own TImageList which will be keeping a big bitmap into memory and will have a function to return a TImage object with given index.

  3. #3

    ImageList.Add

    Yeah that's what I wanted to do. It works if I add the bitmap to the ImageList at the design stage so I thought it'd work at run time too.

    Thanks for clearing it up though, I can spend my time working on something else. I might try writing my own.
    Why are toasters created with a setting that burns the bread to a crisp no sane person could eat?
    <br />Who said Humpty Dumpty was an egg?
    <br />Why are there no 'B' sized batteries?
    <br />Why don't you ever see baby seagulls?

  4. #4

    ImageList.Add

    HI, I am very sorry for confusing you. I've checked it once again and you had right, TImageList splits images. I've tried to load image in the runtime and you had right also - it reads only first row. I'll try to investigate it further.

    After Edition:

    Quite strange thing but all methods allowing loading bitmap use only one dimension parameter - width. So you can obtain some sort of vertical stripes. The method from designtime must be different and separate from TImageList object.


    However writing own splitter component should be easy. You could even use a standard TBitmap component and get a parts of bitmap by CopyRect method.

  5. #5

    ImageList.Add

    Thanks for the info again. Strange that it works differently at run time. I've got not idea how to my own component but I made a procedure that does the job and even rotates the picture to what I want before splitting it up.

    Bit more work to it, but much more flexible
    Why are toasters created with a setting that burns the bread to a crisp no sane person could eat?
    <br />Who said Humpty Dumpty was an egg?
    <br />Why are there no 'B' sized batteries?
    <br />Why don't you ever see baby seagulls?

  6. #6

    ImageList.Add

    Quote Originally Posted by Septimus
    Thanks for the info again. Strange that it works differently at run time. I've got not idea how to my own component but I made a procedure that does the job and even rotates the picture to what I want before splitting it up.

    Bit more work to it, but much more flexible

    Thats great mate I guess in the design time a different api method is called for splitting up images. But since you've already solved the problem, there is nothing to worry about

Bookmarks

Posting Permissions

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