Peted wrote:
Quote
So is the idea, then save the bitmap (256 colours is fine for me) as a
res file, add it to the project, but then what ?
To be clear, you save the bitmap as a bitmap. You need another
program that can add the bitmap to a .res file.
You have 2 types of programs that you can use to get the
bitmap into a .res file. One is a resource editor and the
other is a resource compiler. BCB comes with both. However,
the editor (click Tools | Image Editor) does not support 256
colors so you need to use the resource compiler or some other
editor.
Your program can have one or many .res files. I would
reccommend that you not use the default .res thats generated
by the IDE because the IDE takes a snapshot of it and
frequently rebuilds it - resulting in loss of all your work
unless you delete this and that before you do this and that so
that the snapshot includes your additions. I did it once but
don't recall the exact steps.
This link details all of the steps to create a .res file using the resourse compiler.
www.bcbdev.com/faqs/faq52.htm
In general:
Create a text file with the extension of .rc which
is the source file for the compiler.
Create a text file with the same name as the .rc file but
with the extention of .rh which is the header file to the
source.
Pass the .rc file to the compiler.
Make sure the new .res file is in the same folder as the
target application.
That's all there is to making a .res file (for only a bitmap).
Then to use it, optionally include the .rh so you don't have
duplicate code and get the resource added to a particular unit.
Note that if you add it to more than one form, it does not take
more memory.
#include "MyResource.rh"
#pragma resource "MyResource.res"
There's a bunch of ways to grab a bitmap from a .res file. The
easiest way is to use the built-in method of a TBitmap, of
which there are 2 to pick from. One loads using a string to
identify the bitmap and the other uses a numeric ID. The
reason that there are 2 methods is that it depends on how
the .res was created. If created with an editor, you must use
the string method. Since you're using the compiler, you want
to use the ID method:
Graphics::TBitmap *bmp = new Graphics::TBitmap;
bmp->LoadFromResourceID( (int)HInstance, ID_BITMAP1 );
where ID_BITMAP1 is a #define in your .rh file.
~ JD
Please trim your posts.