var
fileheader: TMyBMPHeader;
infoheader: TMyBMPExtendedHeader;
s: TFilestream;
x, y: integer;
PicData:
Array of Array of TMyBGRQuad;
begin
s := TFileStream.Create('
c:\tmp\01.bmp', fmOpenRead);
try
s.
Read(fileheader, SizeOf(fileheader));
s.
Read(infoheader, SizeOf(infoheader));
finally
s.Free;
end;
with listbox1
do
begin
Items.Clear;
Items.Add('
bfSize: ' + IntToStr(fileheader.bfSize));
Items.Add('
bfReserved: ' + IntToStr(fileheader.bfReserved));
Items.Add('
bfOffBits: ' + IntToStr(fileheader.bfOffBits));
Items.Add('
bfSize: ' + IntToStr(fileheader.bfSize));
Items.Add('
biWidth: ' + IntToStr(infoheader.biWidth));
Items.Add('
biHeight: ' + IntToStr(infoheader.biHeight));
Items.Add('
biPlanes: ' + IntToStr(infoheader.biPlanes));
Items.Add('
biBitCount: ' + IntToStr(infoheader.biBitCount));
Items.Add('
biCompression: ' + IntToStr(infoheader.biCompression));
Items.Add('
biSizeImage: ' + IntToStr(infoheader.biSizeImage));
Items.Add('
biXPelsPerMeter: ' + IntToStr(infoheader.biXPelsPerMeter));
Items.Add('
biYPelsPerMeter: ' + IntToStr(infoheader.biYPelsPerMeter));
Items.Add('
biClrUsed: ' + IntToStr(infoheader.biClrUsed));
Items.Add('
biClrImportant: ' + IntToStr(infoheader.biClrImportant));
end;
s.Position:= fileheader.bfOffBits;
SetLength(PicData, infoheader.biWidth);
//<--Hier bekomme ich immer die Access violation
SetLength(PicData[0], infoheader.biHeight);
if infoheader.biHeight > 0
then
begin
for y:= 0
to infoheader.biHeight
do
begin
for x:= 0
to infoheader.biWidth
do
begin
s.
Read(PicData[x,y], SizeOf(TMyBGRTriple));
end;
end;
end
else
begin
end;
PaintBox1.Width:= infoheader.biWidth;
PaintBox1.Height:= infoheader.biHeight;
for y:= 0
to infoheader.biHeight
do
begin
for x:= 0
to infoheader.biWidth
do
begin
PaintBox1.Canvas.Pixels[x,y]:=
RGB(PicData[x,y].r, PicData[x,y].g, PicData[x,y].b)
end;
end;
end;