 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ulla Guest
|
Posted: Tue Oct 07, 2003 8:25 am Post subject: How to add existing bmp to resource file? |
|
|
Hi all. How do i add several EXISTING bmp files (which i have on
my hard disk) into resource file named "MyResources.res" using
the Builder C++ 4.0 Image Editor? I searched in all the options
of the Image Editor and i did not find any way to add existing
bitmaps into the resource file, i also wasn't able to copy-paste
my bitmaps into the resource. Can someone please help me and
tell me how to do that?
Thanks!
Ulla
|
|
| Back to top |
|
 |
Michel Leunen Guest
|
Posted: Tue Oct 07, 2003 8:51 am Post subject: Re: How to add existing bmp to resource file? |
|
|
Ulla wrote:
| Quote: | Hi all. How do i add several EXISTING bmp files (which i have on
my hard disk) into resource file named "MyResources.res" using
the Builder C++ 4.0 Image Editor? I searched in all the options
of the Image Editor and i did not find any way to add existing
bitmaps into the resource file, i also wasn't able to copy-paste
my bitmaps into the resource. Can someone please help me and
tell me how to do that?
|
You can't using the image editor. Instead, create a MyResources.rc file
with the declarations of your bitmaps and then compile that file into a
..res file using brcc32.exe.
something like:
..rc
#define ID_BMP1 1001
#define ID_BMP2 1002
...
ID_BMP1 BITMAP "Bitmap1.bmp"
ID_BMP2 BITMAP "Bitmap2.bmp"
...
Then compile into a .res
brcc32 -32 MyResources.rc
Michel
--
----------------------------------------
Michel Leunen
mailto:michel (AT) leunen (DOT) com
http://www.leunen.com/cbuilder/
----------------------------------------
|
|
| Back to top |
|
 |
Ulla Guest
|
Posted: Tue Oct 07, 2003 10:46 am Post subject: Re: How to add existing bmp to resource file? |
|
|
Thanks Michel, that is exactly what i did at last, and it's
working very well, i used the instructions from this page:
http://www.bcbdev.com/faqs/faq52.htm
which is very similar to what you asked me to do.
But now i have some "small" problems -
On my form i having TImage which have it's 'Stretch' set to
'true', when i use this code then everything is good and i
can i see the whole image on the diaplay -
Image1->Picture->Bitmap->LoadFromResourceID( (int)HInstance, ID_BITMAP1 );
But if i use this code then i see on the display only pasr of
the image (the upper left side of it) -
Graphics::TBitmap *TestBmp = new Graphics::TBitmap();
TestBmp->LoadFromResourceID( (int)HInstance, ID_BITMAP1 );
Image1->Canvas->Draw( 0, 0, TestBmp );
Why?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Also i don't understand why when i use this code there are so
many flickerings on the display -
Graphics::TBitmap *TestBmp = new Graphics::TBitmap();
for ( int i = 0; i < 2000; i++ )
{
TestBmp->LoadFromResourceID( (int)HInstance, ID_BITMAP1 );
Image1->Canvas->Draw( 0, 0, TestBmp );
Application->ProcessMessages();
TestBmp->LoadFromResourceID( (int)HInstance, ID_BITMAP2 );
Image1->Canvas->Draw( 0, 0, TestBmp );
Application->ProcessMessages();
}
What do i do to stop them?
Thanks!
Ulla
Michel Leunen <mleu (AT) STOPSPAMskynet (DOT) be> wrote:
| Quote: | Ulla wrote:
Hi all. How do i add several EXISTING bmp files (which i have on
my hard disk) into resource file named "MyResources.res" using
the Builder C++ 4.0 Image Editor? I searched in all the options
of the Image Editor and i did not find any way to add existing
bitmaps into the resource file, i also wasn't able to copy-paste
my bitmaps into the resource. Can someone please help me and
tell me how to do that?
You can't using the image editor. Instead, create a MyResources.rc file
with the declarations of your bitmaps and then compile that file into a
.res file using brcc32.exe.
something like:
.rc
#define ID_BMP1 1001
#define ID_BMP2 1002
...
ID_BMP1 BITMAP "Bitmap1.bmp"
ID_BMP2 BITMAP "Bitmap2.bmp"
...
Then compile into a .res
brcc32 -32 MyResources.rc
Michel
|
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Tue Oct 07, 2003 11:34 am Post subject: Re: How to add existing bmp to resource file? |
|
|
Ulla wrote:
| Quote: | On my form i having TImage which have it's 'Stretch' set to
'true',
|
The Stretch property will only have influence during the
load of a file, not while drawing on the canvas.
| Quote: | Also i don't understand why when i use this code there are so
many flickerings on the display -
Graphics::TBitmap *TestBmp = new Graphics::TBitmap();
for ( int i = 0; i < 2000; i++ )
{
TestBmp->LoadFromResourceID( (int)HInstance, ID_BITMAP1 );
Image1->Canvas->Draw( 0, 0, TestBmp );
Application->ProcessMessages();
TestBmp->LoadFromResourceID( (int)HInstance, ID_BITMAP2 );
Image1->Canvas->Draw( 0, 0, TestBmp );
Application->ProcessMessages();
}
|
First you could change that to:
Graphics::TBitmap1 *TestBmp = new Graphics::TBitmap();
Graphics::TBitmap2 *TestBmp = new Graphics::TBitmap();
TestBmp1->LoadFromResourceID( (int)HInstance, ID_BITMAP1 );
TestBmp2->LoadFromResourceID( (int)HInstance, ID_BITMAP2 );
for ( int i = 0; i < 2000; i++ )
{
Image1->Canvas->Draw( 0, 0, TestBmp1 );
Application->ProcessMessages();
Image1->Canvas->Draw( 0, 0, TestBmp2 );
Application->ProcessMessages();
}
delete TestBmp1;
delete TestBmp2;
You could also try:
for ( int i = 0; i < 20; i++ )
{
Image1->Canvas->Draw( 0, 0, TestBmp1 );
Image1->Update();
Sleep(150);
Image1->Canvas->Draw( 0, 0, TestBmp2 );
Image1->Update();
Sleep(150);
}
Both don't flicker here.
Hans.
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Tue Oct 07, 2003 11:38 am Post subject: Re: How to add existing bmp to resource file? |
|
|
Hans Galema wrote:
| Quote: | Graphics::TBitmap1 *TestBmp = new Graphics::TBitmap();
Graphics::TBitmap2 *TestBmp = new Graphics::TBitmap();
|
Aye, aye.
Hans.
|
|
| Back to top |
|
 |
Ulla Guest
|
Posted: Tue Oct 07, 2003 2:14 pm Post subject: Re: How to add existing bmp to resource file? |
|
|
| Quote: | Hans Galema wrote:
Graphics::TBitmap1 *TestBmp = new Graphics::TBitmap();
Graphics::TBitmap2 *TestBmp = new Graphics::TBitmap();
Aye, aye.
Hans.
|
:-)
I tested your both your examples and i can see lot of flickers
in the two of them, in your second example i removed the Sleep
command and did the loop untill 2,000 becouse i don't want
any delays in the display, i need it for a fast graphics at
real-time. When i say Flickering i mean that the switch between
the two images in not smooth, is not plane, when i run this code
i see lot of bright lines comming very fast up and down on the
image, i have 2 bmp files with a blue background, the first have
one red ball at one corner of the image, and the other have a
yellow ball on another corner, when i switch this images very
fast i expect to see one single smooth blue background with 2
balls in it's 2 corners, when i run it the blue background looks
very smooth and nice but the balls are flickering a lot and have
many bright lines running on them.
Thanks, Ulla
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|