Discussion:
Add my own bitmaps into a resource file?
(too old to reply)
Somebody
2007-09-16 20:48:05 UTC
Permalink
Hello,

I want to use a resource file to load my own bitmaps. Previously I have been
using loadfromfile but want to get away from that.

However, I can set up the resource file but it only appears to let me create
a new bitmap. I already have some ready but just can't see the option to add
them. Is it possible? Thanks.

I have the version 3.0 Image editor.
--
Posted via a free Usenet account from http://www.teranews.com
Somebody
2007-09-16 21:10:35 UTC
Permalink
Post by Somebody
Hello,
I want to use a resource file to load my own bitmaps. Previously I have
been using loadfromfile but want to get away from that.
However, I can set up the resource file but it only appears to let me
create a new bitmap. I already have some ready but just can't see the
option to add them. Is it possible? Thanks.
I have the version 3.0 Image editor.
I've managed to do it by creating a new bmp to the size of my original then
opening the original in the Image Editor. I can then copy and paste it into
the new blank bmp into the resource file.

An add option would be nice!
--
Posted via a free Usenet account from http://www.teranews.com
Jamie
2007-09-16 21:29:38 UTC
Permalink
Post by Somebody
Hello,
I want to use a resource file to load my own bitmaps. Previously I have been
using loadfromfile but want to get away from that.
However, I can set up the resource file but it only appears to let me create
a new bitmap. I already have some ready but just can't see the option to add
them. Is it possible? Thanks.
I have the version 3.0 Image editor.
Hmm.
In the past, I've used the Resource compiler to create a *.RES
then in the main program at the top I use {$R name.res}.
the Resource file it self is just a text file.

NAME RTBITMAP file path to find it.

using the BRC32 in the Bin directory of delphi.

use the /? on it first to get a list of commands.
etc..
that's one way
some where along the line, Borland allowed you to
create a resource script file and then you simply
added to your project.

In your program, you then would need to use something
like the FindResource, LoadResource etc...
Or use a bitmap function to loadfromResource.
ect.
--
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
Kent Briggs
2007-09-16 21:14:29 UTC
Permalink
Post by Somebody
Hello,
I want to use a resource file to load my own bitmaps. Previously I have been
using loadfromfile but want to get away from that.
However, I can set up the resource file but it only appears to let me create
a new bitmap. I already have some ready but just can't see the option to add
them. Is it possible? Thanks.
Create a text file with an .rc extension. Then add that file with
Project|Add File in the Delphi IDE. The contents of the .rc file look
like this:

Image1 BITMAP Image1.bmp
Image2 BITMAP Image2.bmp

Then load those in your code like this:

MyBitmap:=TBitmap.Create;
MyBitmap.LoadFromResourceName(hInstance,'Image1');
--
Kent Briggs, ***@spamcop.net
Briggs Softworks, http://www.briggsoft.com
a***@aol.com
2007-09-16 21:56:23 UTC
Permalink
Post by Somebody
Hello,
I want to use a resource file to load my own bitmaps. Previously I have been
using loadfromfile but want to get away from that.
However, I can set up the resource file but it only appears to let me create
a new bitmap. I already have some ready but just can't see the option to add
them. Is it possible? Thanks.
I have the version 3.0 Image editor.
Create a text file with the name of the resource file you will require
(but NOT the same as your .pas file) and a .rc extension. for
example ...

SpeechMike.rc contents
SM1Pro BITMAP "..\Bitmaps\SM1Pro.bmp"
SM1ProBarcode BITMAP "..\Bitmaps\SM1ProBarCode.bmp"
SM1Classic BITMAP "..\Bitmaps\SM1Classic.bmp"

Note the file path names delimited with double quotes for long
filenames. The double quotes are not necessary for an 8.3 short
filename. Double dots mean the parent folder.

Then call BRCC32.exe as follows ...

BRCC32 /v SpeechMike.rc

This would produce a file SpeechMike.res in the same folder as
BRCC32.exe

Then place a {$R <filename> } compiler directive with the resource
file name in the implementation clause of your unit ...

{$R '..\Resources\Compiled Resources\SpeechMike.res'}

In your code declare a bitmap variable and create the bitmap in
code ...

var
FMiniBitMap : TBitmap;

begin
FMiniBitMap := TBitmap.Create;

Then load the bitmap from the resource by allocating the handle
returned from a LoadBitmap() function ...

FMiniBitmap.Handle := LoadBitmap(HInstance, 'SM1ProBarCode');

Resource access is sometimes twitchy regarding identical cases in the
resource name or type, and in the file.

You could also get at the bitmap in a resource by using a
TResourceStream.

Alan Lloyd
Kent Briggs
2007-09-17 00:11:10 UTC
Permalink
Post by a***@aol.com
Then call BRCC32.exe as follows ...
No need for that. Recent versions of Delphi will compile the .rc to .res
for you when you include the .rc file as part of the project.
Post by a***@aol.com
Then place a {$R <filename> } compiler directive with the resource
file name in the implementation clause of your unit ...
Also not needed when the above method is used.
--
Kent Briggs, ***@spamcop.net
Briggs Softworks, http://www.briggsoft.com
Rudy Velthuis
2007-09-17 12:22:00 UTC
Permalink
Post by a***@aol.com
SpeechMike.rc contents
SM1Pro BITMAP "..\Bitmaps\SM1Pro.bmp"
SM1ProBarcode BITMAP "..\Bitmaps\SM1ProBarCode.bmp"
SM1Classic BITMAP "..\Bitmaps\SM1Classic.bmp"
Note the file path names delimited with double quotes for long
filenames. The double quotes are not necessary for an 8.3 short
filename. Double dots mean the parent folder.
Then call BRCC32.exe as follows ...
Newer versions of Delphi will allow you to add the .rc to the project,
and the IDE will take care of calling the resource compiler for you.
--
Rudy Velthuis http://rvelthuis.de

"It was the experience of mystery -- even if mixed with fear --
that engendered religion."
-- Albert Einstein (1879-1955)
Maarten Wiltink
2007-09-16 23:28:13 UTC
Permalink
"Somebody" <***@where.com> wrote in message news:46ed8a8a$0$16337$***@free.teranews.com...
[...]
Post by Somebody
I have the version 3.0 Image editor.
My condolences. It's about as lousy a program as Paint.

That said, it's what I use, too. Call me lazy. Or a masochist.

Groetjes,
Maarten Wiltink
Somebody
2007-09-17 00:35:51 UTC
Permalink
Works splendidly using.

mybitmap.LoadFromResourceName(hinstance,'myresource');

However, I am using G-Soft's FastLIB
http://www.torry.net/authorsmore.php?id=1117 and I can't get it to work with
that. I just end up with a blank square which makes me think it's not
loading the appropriate image.

fastimg1.bmp.LoadFromRes(hInst:Cardinal; ResID:PAnsiChar;
ResType:PAnsiChar);

is what it's asking for so I'm entering

fastimg1.bmp.LoadFromRes(hinstance,'abcdef','bitmap');
fastimg1.repaint;

abcdef is the resource file name. bitmap is the actual word "bitmap".
Even if you don't know this package am I using the correct syntax or barking
up the wrong tree?

Thanks for any pointers.
--
Posted via a free Usenet account from http://www.teranews.com
Somebody
2007-09-17 01:39:04 UTC
Permalink
Post by Somebody
Works splendidly using.
mybitmap.LoadFromResourceName(hinstance,'myresource');
However, I am using G-Soft's FastLIB
http://www.torry.net/authorsmore.php?id=1117 and I can't get it to work
with that. I just end up with a blank square which makes me think it's not
loading the appropriate image.
fastimg1.bmp.LoadFromRes(hInst:Cardinal; ResID:PAnsiChar;
ResType:PAnsiChar);
is what it's asking for so I'm entering
fastimg1.bmp.LoadFromRes(hinstance,'abcdef','bitmap');
fastimg1.repaint;
abcdef is the resource file name. bitmap is the actual word "bitmap".
Even if you don't know this package am I using the correct syntax or
barking up the wrong tree?
Thanks for any pointers.
I also tried rt_bitmap in place of the word 'bitmap' without success.
--
Posted via a free Usenet account from http://www.teranews.com
Jamie
2007-09-17 02:20:12 UTC
Permalink
Post by Somebody
Post by Somebody
Works splendidly using.
mybitmap.LoadFromResourceName(hinstance,'myresource');
However, I am using G-Soft's FastLIB
http://www.torry.net/authorsmore.php?id=1117 and I can't get it to work
with that. I just end up with a blank square which makes me think it's not
loading the appropriate image.
fastimg1.bmp.LoadFromRes(hInst:Cardinal; ResID:PAnsiChar;
ResType:PAnsiChar);
is what it's asking for so I'm entering
fastimg1.bmp.LoadFromRes(hinstance,'abcdef','bitmap');
fastimg1.repaint;
abcdef is the resource file name. bitmap is the actual word "bitmap".
Even if you don't know this package am I using the correct syntax or
barking up the wrong tree?
Thanks for any pointers.
I also tried rt_bitmap in place of the word 'bitmap' without success.
The NAME has to be all in CAPS!
upper case only ..
no lower case.
--
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
Somebody
2007-09-17 02:08:15 UTC
Permalink
Post by Jamie
Post by Somebody
Post by Somebody
Works splendidly using.
mybitmap.LoadFromResourceName(hinstance,'myresource');
However, I am using G-Soft's FastLIB
http://www.torry.net/authorsmore.php?id=1117 and I can't get it to work
with that. I just end up with a blank square which makes me think it's
not loading the appropriate image.
fastimg1.bmp.LoadFromRes(hInst:Cardinal; ResID:PAnsiChar;
ResType:PAnsiChar);
is what it's asking for so I'm entering
fastimg1.bmp.LoadFromRes(hinstance,'abcdef','bitmap');
fastimg1.repaint;
abcdef is the resource file name. bitmap is the actual word "bitmap".
Even if you don't know this package am I using the correct syntax or
barking up the wrong tree?
Thanks for any pointers.
I also tried rt_bitmap in place of the word 'bitmap' without success.
The NAME has to be all in CAPS!
upper case only ..
no lower case.
--
"I'm never wrong, once i thought i was, but was mistaken"
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
Tried that as well Jamie without success.
--
Posted via a free Usenet account from http://www.teranews.com
Rudy Velthuis
2007-09-17 12:20:28 UTC
Permalink
Post by Somebody
Hello,
I want to use a resource file to load my own bitmaps. Previously I
have been using loadfromfile but want to get away from that.
However, I can set up the resource file but it only appears to let me
create a new bitmap.
MyRes.rc:

MYBITMAP BITMAP 'C:\images\MyBitmap.bmp'

Should work fine. Image editor will only let you copy and paste, AFAIK.
--
Rudy Velthuis http://rvelthuis.de

"Sometimes, the best answer is a more interesting question"
-- Terry Pratchett
Loading...