mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 20:36:09 +02:00
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:
parent
b91754876e
commit
cf4069023c
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user