Recent

Author Topic: Define a bitmap inside the code  (Read 9545 times)

Giuseppe Ridinò

  • Full Member
  • ***
  • Posts: 130
Define a bitmap inside the code
« on: April 26, 2004, 10:50:00 pm »
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ò

  • Full Member
  • ***
  • Posts: 130
Define a bitmap inside the code
« Reply #1 on: May 22, 2004, 04:42:25 pm »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 2583
Define a bitmap inside the code
« Reply #2 on: May 25, 2004, 12:45:06 pm »
Can you use a Imagelist ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

RudieD

  • Full Member
  • ***
  • Posts: 234
Define a bitmap inside the code
« Reply #3 on: April 26, 2006, 02:40:50 pm »
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.
The FRED Trainer. (Training FRED with Lazarus/FPC)

Giuseppe Ridinò

  • Full Member
  • ***
  • Posts: 130
Define a bitmap inside the code
« Reply #4 on: April 27, 2006, 12:06:57 pm »
Eheheh... this topic is a bit old! I will check these functionality ASAP since I think I will need them to recode my applications. ;-)

Anonymous

  • Guest
Define a bitmap inside the code
« Reply #5 on: April 27, 2006, 02:28:29 pm »
Hello-

I wrote some code that auto-generates a bitmap image: http://www.sph.sc.edu/comd/rorden/mricron/bounty/
I am not sure if this is what you want. For Windows, I was able to generate a Bitmap directly, but for universal code that works in Linux and Windows, I needed to use IntfGraphics and initially load a sample bitmap from a file. I doubt this is the most elegant solution, but maybe it is a starting point.

 

TinyPortal © 2005-2018