Board index » delphi » how to set palette into a resource file bitmap
Francesco Savastano
![]() Delphi Developer |
Francesco Savastano
![]() Delphi Developer |
how to set palette into a resource file bitmap2005-07-17 10:27:44 PM delphi196 Hello, I have a 256 bmp with a optimized palette. Since the palette is optimized the bmp displays very nicely. Now I want to save into a delphi resource file this bmp. If i open the delphi image editor and create new bmp with 256 color and then i copy and paste from the saved version of my bmp, the resulting palette is not optimized anymore, in other words copying and pasting doesnt copy also the palette. So now the resource bmp looks very ugly. How can i solve this problem, maybe there is another tool to save a bmp into resource file, besides the standard delphi image editor? |
Finn Tolderlund
![]() Delphi Developer |
2005-07-17 11:20:09 PM
Re:how to set palette into a resource file bitmap
"Francesco Savastano" <XXXX@XXXXX.COM>
skrev i en meddelelse news:42da6ad8$XXXX@XXXXX.COM... QuoteHow can i solve this problem, maybe there is another tool to save a bmp PALBMP RCDATA "filename.bmp" Save this files with a *.RC extension. If you have Delphi 5 + add the .RC file to the project and build it. If you have Delphi 4 - you have to compile the .RC file manually using the resource compiler and include the resulting .RES file in the project. -- Finn Tolderlund |
Francesco Savastano
![]() Delphi Developer |
2005-07-18 01:38:06 AM
Re:how to set palette into a resource file bitmap
Hello,
actually I have already a .res file that contains also other resources. So it's already compiled. I am using Delphi 5. The resource file is to be used in a component not in a project, maybe you can advice better on what to do? I dont want to have too many resource files, I'd prefer everything is enclosed into one res file. Thanx, Francesco -- New World Software Creative Tools for Creative People new-world-software.com "Finn Tolderlund" <XXXX@XXXXX.COM>ha scritto nel messaggio Quote
|
Jens Gruschel
![]() Delphi Developer |
2005-07-18 02:06:39 AM
Re:how to set palette into a resource file bitmapQuoteactually I have already a .res file that contains also other resources. So .res file per component (or at least one per package), and one for the project itself (in addition to the one created automatically). Jens |
Francesco Savastano
![]() Delphi Developer |
2005-07-18 02:13:45 AM
Re:how to set palette into a resource file bitmap
Jens I meant I dont want to have more than 1 resource file for the
component. I want to use the one I have and add to it this bmp. Since Finn adviced to create a rc file containing just the bitmap, i wondered instead if there is a way to do this using the already existing resource file? "Jens Gruschel" <XXXX@XXXXX.COM>ha scritto nel messaggio Quote>actually I have already a .res file that contains also other resources. |
Jens Gruschel
![]() Delphi Developer |
2005-07-18 03:48:01 AM
Re:how to set palette into a resource file bitmapQuoteJens I meant I dont want to have more than 1 resource file for the and other data into a .rc file? it is much more flexible. Jens |
Finn Tolderlund
![]() Delphi Developer |
2005-07-18 04:26:23 AM
Re:how to set palette into a resource file bitmap
"Francesco Savastano" <XXXX@XXXXX.COM>
skrev i en meddelelse news:42da9fd2$XXXX@XXXXX.COM... QuoteJens I meant I dont want to have more than 1 resource file for the Finn Tolderlund |
Francesco Savastano
![]() Delphi Developer |
2005-07-18 06:46:22 AM
Re:how to set palette into a resource file bitmapQuoteMaybe that is possible with another resource editor. But I prefer not to further development in it (for example tru color bitmaps are not supported). Do you have some example of home made rc files just to make sure that i will do everything right with oyur approuch? |
Jens Gruschel
![]() Delphi Developer |
2005-07-18 07:20:35 AM
Re:how to set palette into a resource file bitmapQuoteDo you have some example of home made rc files just to make sure that i will TRAYICON00 ICON TrayDefault.ico TRAYICON01 ICON TrayOutline.ico TRAYICON02 ICON TrayP.ico TRAYICON03 ICON TrayS.ico Really simple. You can also find many articles about resource files including better examples than mine. Jens P.S. I added "Compile with BRCC32" to the context menu for .rc files to compile them easily, but as Finn already said, depending on the Delphi version you are using, you don't even have to do this manually. |
Mr. X
![]() Delphi Developer |
2005-07-18 03:32:02 PM
Re:how to set palette into a resource file bitmap
Hi
You can try Resource Builder from SIComponents.com ... its a great resource editor for including even 24 bit bitmap resources. BEst Regards "Francesco Savastano" <XXXX@XXXXX.COM> writes news:42da6ad8$XXXX@XXXXX.COM... Quote
|
Francesco Savastano
![]() Delphi Developer |
2005-07-18 07:33:49 PM
Re:how to set palette into a resource file bitmap
I tried to use this program but it didnt work well for me: I have put a
24bit bmp into my resourse file, then in my component I load this bitmap into an imageList: ImageList_Rotatebuttons.ResInstLoad( HInstance, rtBitmap, 'ROTATEBTNS1', clFuchsia ); then I take various small bmps from the imagelist in this way: tmpbmp := tbitmap.create; tmpbmp.PixelFormat := pf24bit; try ImageList_Rotatebuttons.GetBitmap(3+i,tmpbmp) tmpbmp.PixelFormat := pf24bit; // then i display the bitmap on my component canvas fDrawingBmp.Canvas.draw(xb,yb,tmpbmp); finally tmpbmp.free; end; The problem is that the bitmaps don't display correctly: they have wrong colors and lost many details. Maybe i do something wrong in my code, or it is just the Resource Builder program doesnt work well? -- New World Software Creative Tools for Creative People new-world-software.com "Mr. X" <XXXX@XXXXX.COM>ha scritto nel messaggio QuoteHi |
Francesco Savastano
![]() Delphi Developer |
2005-07-18 08:18:24 PM
Re:how to set palette into a resource file bitmap
I did it as you said but the bitmaps displayed have wrong colors:
Maybe I am doing something wrong in my code? In my component the resource bitmap is retrieved into an ImageList and then the various bmps inside the imagelist are drawn on my component's canvas: ImageList_Rotatebuttons.ResInstLoad( HInstance, rtBitmap, 'ROTATEBTNS1', clFuchsia ); then I take various small bmps from the imagelist in this way: tmpbmp := tbitmap.create; tmpbmp.PixelFormat := pf24bit; try ImageList_Rotatebuttons.GetBitmap(i,tmpbmp) tmpbmp.PixelFormat := pf24bit; // then i display the bitmap on my component canvas fDrawingBmp.Canvas.draw(xb,yb,tmpbmp); finally tmpbmp.free; end; The problem is that the bitmaps don't display correctly: they have wrong colors and lost many details. Maybe i do something wrong in my code? I have like the feeling that something in the imagelist messes up the colors.. Thanx in advance for your answers, Francesco. "Jens Gruschel" <XXXX@XXXXX.COM>ha scritto nel messaggio Quote>Do you have some example of home made rc files just to make sure that i |
Jens Gruschel
![]() Delphi Developer |
2005-07-18 11:04:56 PM
Re:how to set palette into a resource file bitmapQuoteI have like the feeling that something in the imagelist messes up the you can do it more directly. Create a TBitmap instead, and load your bitmap from the resource. Now draw the part you want to with BitBlt. Something like: BitBlt(fDrawingBmp.Canvas.Handle, xb, yb, GlyphWidth, GlyphHeight, BitmapFromRes.Canvas.Handle, I * GlyphWidth, 0); Jens |
Francesco Savastano
![]() Delphi Developer |
2005-07-19 12:27:08 AM
Re:how to set palette into a resource file bitmap
Thx for the hint Jens, infact I removed the imagelist and used a plain
TBitmap to read the strip from the resource files. Now everything works ok.. Francesco "Jens Gruschel" <XXXX@XXXXX.COM>ha scritto nel messaggio Quote>I have like the feeling that something in the imagelist messes up the |
Igor Siticov
![]() Delphi Developer |
2005-07-19 01:33:56 PM
Re:how to set palette into a resource file bitmap
Hello,
Resource Builder doesn't make any conversions or modifications to original bitmaps while compiling them to RES. As well as it supports bitmaps with custom palettes. The data loss could occur while loading image to the image list. Try to create manually your image list with the following code: ImageList_Rotatebuttons.Handle := ImageList_Create(32, 32, ILC_COLOR24, 4, 4); // 32, 32 means 32x32 pictures in image list Please let us know if this helps. "Francesco Savastano" <XXXX@XXXXX.COM> writes news:XXXX@XXXXX.COM... QuoteI tried to use this program but it didnt work well for me: I have put a |