Board index » delphi » 16 color and 256 color bitmaps in a RES file

16 color and 256 color bitmaps in a RES file

I have created two different MAINICONS for my application:  one at 16
colors and the other at 256 colors.  At this time, I am using the RES
file Delphi creates for my main program and adding a "new" icon to
MAINICONS.  Now that I have these two icons, how do I get my Delphi 3.02
program to use them depending upon the number of colors being used on
the desktop.  I was under the impression Win95 does this automatically
but when I switch colors my 256 color icon becomes really ugly (i.e.,
Windows is not using my 16 color icon.  It is converting my 256 color
icon to 16 colors).

I have a similar question concerning the use of several bitmaps in a
resource file.  I have created a splash screen.  I know I need to create
a RES file with both 16 colors and 256 colors but how do I make my form
use the correct bmp file depending on colors used on the desktop.

In addition, I keep trying to paste my nice looking bitmaps and icons
into the Image Editor and it keeps changing colors on me, rendering all
my pictures useless (i.e., ugly).  Is there a way to make it use my
pictures exactly as they are.  For some reason, Image Editor does not
allow you to paste an image directly into the RES file.  Why is this and
is there a way around it?  I believe this is my problem since the Image
Editor is automatically assuming I want strictly Windows system colors
and my files are being converted that way.

Any help would be greatly appreciated.

Thanks in advance,

...Wade...

 

Re:16 color and 256 color bitmaps in a RES file


Three things:

1st:
Do not use the project's .RES file to add resources to your project, because
this file gets overwritten all the time, and may loose all the resources you
place in it. Create a a new .RES file and add ($R newresfile.res}  to the
project source (or to any unit in the project).

2st:
The selection of icons is made automagically by Windows. You don't have
control (from the Delphi app) over which icon will be shown for your
application. The only thing you can do is to put the right icons in the
right sequence in the resource file and delete the project's resource file
(I mean it!). Here's the order:

icon#     Description
  1           16 colors large icon (16 x 16)
  2           16 colors small icon (16 x 16)
  3            256 colors large icon
  4           256 colors small icon

You have to define the resource type as 3, which is RT_ICON. When you define
the resource type simply as ICON, the resource gets compiled as
RT_GROUP_ICON (type 14), which has another application than being used as
shell icons.

Here's an example of what such resource file (.RC) would look like:

#define RTICON 3
1 RTICON "c:\large16c32x32.ico"
2 RTICON "c:\small16c16x16.ico"
3 RTICON "c:\large256c32x32.ico"
4 RTICON "c:\small256c16x16.ico"

All you have to do now is to compile the .RC file (using BRCC32.EXE) and
link the compiled resource file to your application.

Yours,

- - - - - - - - - - - - - - - - - - - - - - -
Alex Simonetti Abreu
Belo Horizonte, MG, Brazil

Athena's Home: http://www.bhnet.com.br/~simonet
- - - - - - - - - - - - - - - - - - - - - - -

Quote
Thomas W. Earle wrote in message <357FDA66.CAC4D...@noaa.gov>...
>I have created two different MAINICONS for my application:  one at 16
>colors and the other at 256 colors.  At this time, I am using the RES
>file Delphi creates for my main program and adding a "new" icon to
>MAINICONS.  Now that I have these two icons, how do I get my Delphi 3.02
>program to use them depending upon the number of colors being used on
>the desktop.  I was under the impression Win95 does this automatically
>but when I switch colors my 256 color icon becomes really ugly (i.e.,
>Windows is not using my 16 color icon.  It is converting my 256 color
>icon to 16 colors).

>I have a similar question concerning the use of several bitmaps in a
>resource file.  I have created a splash screen.  I know I need to create
>a RES file with both 16 colors and 256 colors but how do I make my form
>use the correct bmp file depending on colors used on the desktop.

>In addition, I keep trying to paste my nice looking bitmaps and icons
>into the Image Editor and it keeps changing colors on me, rendering all
>my pictures useless (i.e., ugly).  Is there a way to make it use my
>pictures exactly as they are.  For some reason, Image Editor does not
>allow you to paste an image directly into the RES file.  Why is this and
>is there a way around it?  I believe this is my problem since the Image
>Editor is automatically assuming I want strictly Windows system colors
>and my files are being converted that way.

>Any help would be greatly appreciated.

>Thanks in advance,

>...Wade...

Other Threads