L
liwenbin
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
fileheader:TBitmapFileHeader;
infoheader:TBitmapInfoHeader;
stream:TFileStream;
localbmp:TBitmap;
linelen:integer;
clipleft,cliptop,clipwidth,clipheight:integer;
i:integer;
begin
Self.DoubleBuffered:=true;
cliptop:=0;
clipleft:=0;
clipwidth:=Image1.Width;
clipheight:=Image1.Height;
stream:=TFileStream.Create('test.bmp',fmopenread or fmsharedenywrite);
localbmp:=TBitmap.Create;
stream.Read(fileheader,sizeof(TBitmapFileHeader));
stream.Read(infoheader,sizeof(TBitmapinfoHeader));
localbmp.Width:=clipwidth;
localbmp.Height:=clipheight;
localbmp.PixelFormat:=pf24Bit;
linelen:=(ByteCount * infoheader.biHeight +3) shr 2 shl 2;
for i:= cliptop to cliptop + clipheight -1 do
begin
stream.Position:=integer(fileheader.bfOffBits)+ linelen *(infoheader.biHeight-1-i)+
byteCount * clipleft
stream.Read(localbmp.scanline[i-cliptop]^,clipwidth * byteCount );
end;
Image1.Picture.Assign(localbmp);
end;
var
fileheader:TBitmapFileHeader;
infoheader:TBitmapInfoHeader;
stream:TFileStream;
localbmp:TBitmap;
linelen:integer;
clipleft,cliptop,clipwidth,clipheight:integer;
i:integer;
begin
Self.DoubleBuffered:=true;
cliptop:=0;
clipleft:=0;
clipwidth:=Image1.Width;
clipheight:=Image1.Height;
stream:=TFileStream.Create('test.bmp',fmopenread or fmsharedenywrite);
localbmp:=TBitmap.Create;
stream.Read(fileheader,sizeof(TBitmapFileHeader));
stream.Read(infoheader,sizeof(TBitmapinfoHeader));
localbmp.Width:=clipwidth;
localbmp.Height:=clipheight;
localbmp.PixelFormat:=pf24Bit;
linelen:=(ByteCount * infoheader.biHeight +3) shr 2 shl 2;
for i:= cliptop to cliptop + clipheight -1 do
begin
stream.Position:=integer(fileheader.bfOffBits)+ linelen *(infoheader.biHeight-1-i)+
byteCount * clipleft
stream.Read(localbmp.scanline[i-cliptop]^,clipwidth * byteCount );
end;
Image1.Picture.Assign(localbmp);
end;