program project1;
{$IfDef Windows}
{$AppType Console}
{$EndIf Windows}
uses
SysUtils, Classes, BMPcomn;
type
TFullBitmapHeader = packed record
BitMapFileHeader: TBitMapFileHeader;
BitMapInfoHeader: TBitMapInfoHeader;
end;
function GetBitmapHeader(const AFilename: string): TFullBitmapHeader;
var
FileStream: TFileStream;
begin
FileStream := TFileStream.Create(AFilename, fmOpenRead);
try
FillChar(Result, SizeOf(Result), 0);
FileStream.Position := 0;
FileStream.Read(Result.BitMapFileHeader.bfType, SizeOf(Result.BitMapFileHeader.bfType));
FileStream.Read(Result.BitMapFileHeader.bfSize, SizeOf(Result.BitMapFileHeader.bfSize));
FileStream.Read(Result.BitMapFileHeader.bfReserved, SizeOf(Result.BitMapFileHeader.bfReserved));
FileStream.Read(Result.BitMapFileHeader.bfOffset, SizeOf(Result.BitMapFileHeader.bfOffset));
FileStream.Read(Result.BitMapInfoHeader.Size, SizeOf(Result.BitMapInfoHeader.Size));
FileStream.Read(Result.BitMapInfoHeader.Width, SizeOf(Result.BitMapInfoHeader.Width));
FileStream.Read(Result.BitMapInfoHeader.Height, SizeOf(Result.BitMapInfoHeader.Height));
FileStream.Read(Result.BitMapInfoHeader.Planes, SizeOf(Result.BitMapInfoHeader.Planes));
FileStream.Read(Result.BitMapInfoHeader.BitCount, SizeOf(Result.BitMapInfoHeader.BitCount));
FileStream.Read(Result.BitMapInfoHeader.Compression, SizeOf(Result.BitMapInfoHeader.Compression));
FileStream.Read(Result.BitMapInfoHeader.SizeImage, SizeOf(Result.BitMapInfoHeader.SizeImage));
FileStream.Read(Result.BitMapInfoHeader.XPelsPerMeter, SizeOf(Result.BitMapInfoHeader.XPelsPerMeter));
FileStream.Read(Result.BitMapInfoHeader.YPelsPerMeter, SizeOf(Result.BitMapInfoHeader.YPelsPerMeter));
FileStream.Read(Result.BitMapInfoHeader.ClrUsed, SizeOf(Result.BitMapInfoHeader.ClrUsed));
FileStream.Read(Result.BitMapInfoHeader.ClrImportant, SizeOf(Result.BitMapInfoHeader.ClrImportant));
finally
FileStream.Free;
end;
end;
var
BitmapHeader: TFullBitmapHeader;
begin
WriteLn('Quick Bitmap Info by KodeZwerg.');
if FileExists(ParamStr(1)) then
begin
BitmapHeader := GetBitmapHeader(ParamStr(1));
WriteLn('Type: ' + IntToHex(Swap(BitmapHeader.BitMapFileHeader.bfType), SizeOf(BitmapHeader.BitMapFileHeader.bfType)));
WriteLn('Filesize: ' + IntToStr(BitmapHeader.BitMapFileHeader.bfSize));
WriteLn('Reserved: ' + IntToHex(Swap(BitmapHeader.BitMapFileHeader.bfReserved), SizeOf(BitmapHeader.BitMapFileHeader.bfReserved)));
WriteLn('Offset: ' + IntToStr(BitmapHeader.BitMapFileHeader.bfOffset));
WriteLn('Structure Size: ' + IntToStr(BitmapHeader.BitMapInfoHeader.Size));
WriteLn('Width: ' + IntToStr(BitmapHeader.BitMapInfoHeader.Width));
WriteLn('Height: ' + IntToStr(BitmapHeader.BitMapInfoHeader.Height));
WriteLn('Planes: ' + IntToStr(BitmapHeader.BitMapInfoHeader.Planes));
WriteLn('Bits Per Pixel: ' + IntToStr(BitmapHeader.BitMapInfoHeader.BitCount));
WriteLn('Compression Method: ' + IntToStr(BitmapHeader.BitMapInfoHeader.Compression));
WriteLn('Image Size: ' + IntToStr(BitmapHeader.BitMapInfoHeader.SizeImage));
WriteLn('Horizontal Resolution: ' + IntToStr(BitmapHeader.BitMapInfoHeader.XPelsPerMeter));
WriteLn('Vertical Resolution: ' + IntToStr(BitmapHeader.BitMapInfoHeader.YPelsPerMeter));
WriteLn('Colors Used: ' + IntToStr(BitmapHeader.BitMapInfoHeader.ClrUsed));
WriteLn('Colors Important: ' + IntToStr(BitmapHeader.BitMapInfoHeader.ClrImportant));
end
else
WriteLn('Usage: ' + ExtractFileName(ParamStr(0)) + ' "image.bmp"');
WriteLn('');
WriteLn('Done.');
{$IfDef Windows}
ReadLn;
{$EndIf Windows}
end.