Forum > Graphics

Define a bitmap inside the code

(1/2) > >>

Giuseppe Ridinò:
I've got a problem and I hope you can give me a solution (I know that this problem may sound trivial,... but it ain't to me)  :oops: :

How can I define a simple image without loading it from a file?

 :arrow: For example:
1. I have a tile image, sized MxN
2. Each tile is taken from a small set of bitmaps, (let's say 1..Nt)
3. When my image should change I will copy the appropiate bitmap to the changed set.

 :!: The point is that I don't want to load the bitmaps from a file, but I want to define them in the code, as a constant or in other way, something like:
BitMap1: array[1..8,1..8] = (....);

Any suggestion?

Thanks in advance  :P

Giuseppe Ridinò:
Please help me!
I tryed the following:
const
  Data: array[0..7,0..7] of LongWord = (
    ($0000FF, $0000FF,..... ),
    .....
  )
In this way I define the 8x8 icon with the needed Tcolors.

Then I tryed:
Icon:=TBitmap.Create;
Icon.ReleaseHandle;
Icon.Handle:=CreateBitMap(8,8,1,1,@Data);

The application is compiled and runs, but when I try to copy this Icon using
Image.Picture.Bitmap.Canvas.CopyRect
I get wrong (... I mean unexpected for me) results.
What's wrong?
Thanks in advance for any help!  :D

Marc:
Can you use a Imagelist ?

RudieD:
Last time I tried the ImageList, I could not replace the Bitmaps during runtime. I'll try it over the weekend again. If you don't want to change them during runtime, it works fine.

Giuseppe Ridinò:
Eheheh... this topic is a bit old! I will check these functionality ASAP since I think I will need them to recode my applications. ;-)

Navigation

[0] Message Index

[#] Next page

Go to full version