• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

Bitmap with more than 256 colors in resource file ?

I think the title says everithing :-)
Thanks for answers
               Robert
0
rpetruni
Asked:
rpetruni
  • 5
  • 5
1 Solution
 
intheCommented:
see here for explaination:

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

Regards Barry
0
 
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
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now