rpetruni
asked on
Bitmap with more than 256 colors in resource file ?
I think the title says everithing :-)
Thanks for answers
Robert
Thanks for answers
Robert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.C reate(HIns tance, 'JPEG1', RT_RCDATA); ResStrm.SaveToFile('c:\tem p\restst.j pg');
ResStrm.Destroy;
end;
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.C
ResStrm.Destroy;
end;
If BRCC32.EXE reports an error then there must be something wrong with the resource script.
Alex
Alex
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..
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..
ASKER
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
"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
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
was the bitmap converted from some other image format?it may have wrong header information.
BorgsAssimilate@Aol.Com
ASKER
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
Robert
ASKER
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(Ime Filea)-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
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(Ime
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
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..
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..
ASKER
Thanks
ASKER
How to put it in resource file???
Brcc32 gives an error, Image editor in Delphi supports only 256 color bitmaps, Resource workshop also...
?
Robert