whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

38 Visitors Online


 
...get informations about bmp files?
Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
[ Print tip ]  

Tip Rating (3):  
     


{
  This tip show, how to get the filesize, width, height, bitcount and color used
  from a bitmap.

  Dieses Beispiel zeigt, wie man Dateigrösse, breite, höhe, Farbtiefe und Farbanzahl
  von einem Bitmap ausliest.
}


procedure TForm1.Button1Click(Sender: TObject);
var
  
fileheader: TBitmapfileheader;
  infoheader: TBitmapinfoheader;
  s: TFilestream;
begin
  
s := TFileStream.Create('c:\YourBitmap.bmp', fmOpenRead);
  try
    
s.Read(fileheader, SizeOf(fileheader));
    s.Read(infoheader, SizeOf(infoheader));
  finally
    
s.Free;
  end;
  listbox1.Items.Clear;
  listbox1.Items.Add('Filesize:    ' + IntToStr(fileheader.bfSize));
  listbox1.Items.Add('Width:       ' + IntToStr(infoheader.biWidth));
  listbox1.Items.Add('Height:      ' + IntToStr(infoheader.biHeight));
  listbox1.Items.Add('BitCount:    ' + IntToStr(infoheader.biBitCount));
  listbox1.Items.Add('Used:        ' + IntToStr(infoheader.biClrUsed));
end;

{
  BitCount:
  1 = black/white
  4 = 16 colors
  8 = 256 colors
}


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners