Board index » delphi » Excessive size of a /tbitmap file

Excessive size of a /tbitmap file

I am a 'programmer' that moonlights as an OBGYN in the day! I've
computerised all my records (Started in UCSD Pascal, migrated to TP 4..7,
then D1,D2,D3) and now do little drawings following some examinations. These
are saved to disc.

I've come across a little problem that someone might be able to help:

I create and save a 200x200 monochrome bitmap, when I save it to disc, the
size is an incredible 156K.
Loading the same file into paint.exe and setting its attribute to monochrome
results in a file of 6K.
Am I doing anything wrong in Delphi (D3 in W98SE)?
Here is a code snippet:

MyBitmap := TBitmap.Create;
With MyBitmap do begin
  Width:=200; Height :=200; Monochrome:=true;  //specify 200x 200 in B&W
  Picture.SaveToFile('MyBitmap.BMP')                //generated a 156K
file!!
  end;

I'd be grateful for any help, or is this a little 'feature' in Delphi?

Cheers,

Laurie Boshell.

 

Re:Excessive size of a /tbitmap file


On Thu, 31 Jan 2002 22:08:22 +1100, "laurie boshell"

Quote
<lau...@pnc.com.au> wrote:

>I create and save a 200x200 monochrome bitmap, when I save it to disc, the
>size is an incredible 156K.
>Loading the same file into paint.exe and setting its attribute to monochrome
>results in a file of 6K.
>Am I doing anything wrong in Delphi (D3 in W98SE)?
>Here is a code snippet:

>MyBitmap := TBitmap.Create;
>With MyBitmap do begin
>  Width:=200; Height :=200; Monochrome:=true;  //specify 200x 200 in B&W
>  Picture.SaveToFile('MyBitmap.BMP')                //generated a 156K
>file!!
>  end;

I think it's a simple error:  You're saving Picture, not MyBitmap.
Just change the 4th line to

  SaveToFile('MyBitmap.BMP');

This works in D5.  If it doesn't work for you, you might try changing
PixelFormat to pf1bit.  This should do the same thing as setting
Monochrome to true, but maybe there was a bug in D3.

Duncan Murdoch

Other Threads