Bitmap with more than 256 colors in resource file ?

I think the title says everithing :-)
Thanks for answers
               Robert
LVL 1
rpetruniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
see here for explaination:

http://www.borland.com/devsupport/delphi/ti/TI1081D.html

Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rpetruniAuthor Commented:
ok, i was not clear enough...
How to put it in resource file???
Brcc32 gives an error, Image editor in Delphi supports only 256 color bitmaps, Resource workshop also...
?
                        Robert
0
intheCommented:
oh i see the problem :-)

you could convert it to jpeg etc and save in res file as rc_data instead of bitmap .i can give conversion routines if you need ,here is some code to get jpeg from res:

procedure TForm1.formcreate(Sender: TObject);
var
  ResStrm: TResourceStream;
begin
    ResStrm:=TResourceStream.Create(HInstance, 'JPEG1', RT_RCDATA);     ResStrm.SaveToFile('c:\temp\restst.jpg');
    ResStrm.Destroy;
end;
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

simonetCommented:
If BRCC32.EXE reports an error then there must be something wrong with the resource script.

Alex
0
intheCommented:
good point what is the error that you get?
i just created a res file with rc looking like:

many_colors_bitmap BITMAP c:\lightemple.bmp

this bitmap has just over 21000 colors but brcc32 compiled with no probs ,but then the prob starts, a normal routine for putting a bitmap from a res file to a image fails with invaid graphic but it works on a bitmap less than 256 colors..
0
rpetruniAuthor Commented:
I don't understand why , but i have about 20 bitmaps in rc file, and brcc32 report error ONLY when i place bitmap with more than 256 colors. The error is:
"Error [name of the rc file] 17 24 : Invalid bitmap format"
17 - is the line in rc file where the error occured, and 24 has something to do with bitmap properties (i think)
               Robert

0
intheCommented:
would you mind sending the bitmap to me?
was the bitmap converted from some other image format?it may have wrong header information.

BorgsAssimilate@Aol.Com
0
rpetruniAuthor Commented:
Yes it was converted from ico to bmp whit my code, but i think that i was having same error when creating a bitmap in Paint...
                          Robert

0
rpetruniAuthor Commented:
I WAS WRONG, bitmap created in paint is OK for brcc32...

Header of bmp created in paint
copyying and pasting bitmap

42 4D 36 08 00 00 00 00 00 00
36 00 00 00 28 00 00 00 20 00
00 00 20 00 00 00 01 00 10 00
00 00 00 00 00 08 00 00 00 00
00 00 00 00 00 00 00 00 00 00

Header of bitmap brcc32 has problems
recognising:

42 4D 36 0C 00 00 00 00 00 00
36 00 00 00 28 00 00 00 20 00
00 00 20 00 00 00 01 00 18 00
00 00 00 00 00 0C 00 00 CE 0E
00 00 D8 0E 00 00 00 00 00 00

Upper Bitmap was created like this :

     BMP := TBitmap.Create;
     BMP.Width := Image2.Picture.Icon.Width;
     BMP.Height := Image2.Picture.Icon.Height;
     BMP.Canvas.Draw(0,0, Image2.Picture.Icon);
     BMP.SaveToFile(Putanja + copy(ImeFilea,1,length(ImeFilea)-4) + '-' + IntToStr(x)+'.bmp');
     BMP.Free;

What is the reason for header differences?
Ok, since the thing is working when i copy/paste the old image in new
one, so Inthe, answer is right - there is something wrong with header...
I would like to know why?, and what
Thanks
0
intheCommented:
hi
i dunno why the header info wasnt saved properly maybe Image2.Picture.Icon
should be Image2.Picture.graphic;
i see that opening a bad file in paint etc and resaving it should put things right.
there is some stuff here about bitmap header not being right:
http://support.microsoft.com/support/kb/articles/q216/2/05.asp

try this to convert:

procedure ConvertIconToBitmap( IcoFile,BmpFile : string );
var
  Icon1 : TIcon;
  Bitmap1 : TBitmap;
begin
  Icon1 := TIcon.Create;
  Icon1.LoadFromFile(IcoFile);
  Bitmap1 := TBitmap.Create;
  Bitmap1.Height := Icon1.Height;
  Bitmap1.Width := Icon1.Width;
  Bitmap1.Canvas.Draw(0, 0, Icon1);
  Bitmap1.SaveToFile(BmpFile);
  Bitmap1.Free;
  Icon1.Free;
end;


you might take a look around http://www.efg2.com/Lab/Library/
but i didnt find any mention of this problem before..

0
rpetruniAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.