graphics:

- prevent accessing data outside bounds (when copying data from source to destination with bigger alignment. e.g word -> dword)
- fix win2000 bug with wrongly reported bmWidthBytes (they are calculated by win2000 sometimes as for word alignment while in fact they have dword alignment since all bitmap sections are dword aligned). fixes issue with shifted component images in win2000 ide

git-svn-id: trunk@12825 -
This commit is contained in:
paul 2007-11-11 12:51:38 +00:00
parent b91754876e
commit cf4069023c
2 changed files with 5 additions and 3 deletions

View File

@ -396,7 +396,7 @@ begin
FillByte(DstPtr[0], ASize, 0);
end
else begin
LineBytes := RS;
LineBytes := Min(RS, ARowStride);
if H <> LineCount
then FillByte(DstPtr[0], ASize, 0);
end;

View File

@ -1468,18 +1468,20 @@ var
StartScan: Integer;
begin
SrcLineOrder := GetBitmapOrder(AWinBmp, ABitmap);
SrcLineBytes := (AWinBmp.bmWidthBytes + 3) and not 3;
if AWinBmp.bmBits <> nil
then begin
// this is bitmapsection data :) we can just copy the bits
// We cannot trust windows with bmWidthBytes. Use SrcLineBytes which takes
// DWORD alignment into consideration
with AWinBmp do
Result := CopyImageData(bmWidth, bmHeight, bmWidthBytes, bmBitsPixel, bmBits, ARect, SrcLineOrder, ALineOrder, ALineEnd, AData, ADataSize);
Result := CopyImageData(bmWidth, bmHeight, SrcLineBytes, bmBitsPixel, bmBits, ARect, SrcLineOrder, ALineOrder, ALineEnd, AData, ADataSize);
Exit;
end;
// retrieve the data though GetDIBits
SrcLineBytes := (AWinBmp.bmWidthBytes + 3) and not 3;
// initialize bitmapinfo structure
Info.Header.biSize := sizeof(Info.Header);