mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 10:59:14 +02:00
* use sections
git-svn-id: trunk@12356 -
This commit is contained in:
parent
faad6ef6af
commit
960de2744a
@ -383,7 +383,6 @@ var
|
|||||||
DC, TmpDC: HDC;
|
DC, TmpDC: HDC;
|
||||||
OldBmp, OldTmpBmp, SrcBmp, DstBmp, TmpBmp, AlphaBmp: HBITMAP;
|
OldBmp, OldTmpBmp, SrcBmp, DstBmp, TmpBmp, AlphaBmp: HBITMAP;
|
||||||
StretchSrc: Boolean;
|
StretchSrc: Boolean;
|
||||||
SrcWinBmp, DstWinBmp: TBitmap;
|
|
||||||
SrcSection, DstSection: TDIBSection;
|
SrcSection, DstSection: TDIBSection;
|
||||||
Info: record
|
Info: record
|
||||||
Header: TBitmapInfoHeader;
|
Header: TBitmapInfoHeader;
|
||||||
@ -419,31 +418,31 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// get source info
|
// get source info, atleast bitmap, section if available
|
||||||
SrcBmp := GetCurrentObject(hdcSrc, OBJ_BITMAP);
|
SrcBmp := GetCurrentObject(hdcSrc, OBJ_BITMAP);
|
||||||
if GetObject(SrcBmp, SizeOf(SrcWinBmp), @SrcWinBmp) = 0 then Exit(False);
|
if GetObject(SrcBmp, SizeOf(SrcSection), @SrcSection) = 0 then Exit(False);
|
||||||
if nXOriginSrc + nWidthSrc > SrcWinBmp.bmWidth then Exit(False);
|
if nXOriginSrc + nWidthSrc > SrcSection.dsBm.bmWidth then Exit(False);
|
||||||
if nYOriginSrc + nHeightSrc > SrcWinBmp.bmHeight then Exit(False);
|
if nYOriginSrc + nHeightSrc > SrcSection.dsBm.bmHeight then Exit(False);
|
||||||
|
|
||||||
if (blendFunction.AlphaFormat = AC_SRC_ALPHA) and (SrcWinBmp.bmBitsPixel <> 32) then Exit; // invalid
|
if (blendFunction.AlphaFormat = AC_SRC_ALPHA) and (SrcSection.dsBm.bmBitsPixel <> 32) then Exit(False); // invalid
|
||||||
|
|
||||||
// get destination info
|
// get destination info, atleast bitmap, section if available
|
||||||
DstBmp := GetCurrentObject(hdcDest, OBJ_BITMAP);
|
DstBmp := GetCurrentObject(hdcDest, OBJ_BITMAP);
|
||||||
if (DstBmp = 0) or (GetObject(DstBmp, SizeOf(DstWinBmp), @DstWinBmp) = 0)
|
if (DstBmp = 0) or (GetObject(DstBmp, SizeOf(DstSection), @DstSection) = 0)
|
||||||
then begin
|
then begin
|
||||||
// GetCurrentObject can only be used on memory devices,
|
// GetCurrentObject can only be used on memory devices,
|
||||||
// so fill in some values manually
|
// so fill in some values manually
|
||||||
DstWinBmp.bmWidth := GetDeviceCaps(hdcDest, HORZRES);
|
DstSection.dsBm.bmWidth := GetDeviceCaps(hdcDest, HORZRES);
|
||||||
DstWinBmp.bmHeight := GetDeviceCaps(hdcDest, VERTRES);
|
DstSection.dsBm.bmHeight := GetDeviceCaps(hdcDest, VERTRES);
|
||||||
DstWinBmp.bmBitsPixel := GetDeviceCaps(hdcDest, BITSPIXEL);
|
DstSection.dsBm.bmBitsPixel := GetDeviceCaps(hdcDest, BITSPIXEL);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// docs doesn't require dest retangle inside dest.
|
// docs doesn't require dest retangle inside dest.
|
||||||
// however if dest rect is outside the destination, we're done here
|
// however if dest rect is outside the destination, we're done here
|
||||||
if nXOriginDest + nWidthDest < 0 then Exit(True);
|
if nXOriginDest + nWidthDest < 0 then Exit(True);
|
||||||
if nYOriginDest + nHeightDest < 0 then Exit(True);
|
if nYOriginDest + nHeightDest < 0 then Exit(True);
|
||||||
if nXOriginDest >= DstWinBmp.bmWidth then Exit(True);
|
if nXOriginDest >= DstSection.dsBm.bmWidth then Exit(True);
|
||||||
if nYOriginDest >= DstWinBmp.bmHeight then Exit(True);
|
if nYOriginDest >= DstSection.dsBm.bmHeight then Exit(True);
|
||||||
|
|
||||||
// setup info shared by alpha, source and destination bytes
|
// setup info shared by alpha, source and destination bytes
|
||||||
FillChar(Info, sizeof(Info), 0);
|
FillChar(Info, sizeof(Info), 0);
|
||||||
@ -469,7 +468,7 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
// create alpha source data
|
// create alpha source data
|
||||||
R := Rect(nXOriginSrc, nYOriginSrc, nXOriginSrc + nWidthSrc, nYOriginSrc + nHeightSrc);
|
R := Rect(nXOriginSrc, nYOriginSrc, nXOriginSrc + nWidthSrc, nYOriginSrc + nHeightSrc);
|
||||||
if not GetBitmapBytes(SrcBmp, R, rileDWordBoundary, SrcBytesPtr, SrcSize) then Exit;
|
if not GetBitmapBytes(SrcBmp, R, rileDWordBoundary, SrcBytesPtr, SrcSize) then Exit(False);
|
||||||
|
|
||||||
// set info to source size
|
// set info to source size
|
||||||
Info.Header.biWidth := nWidthSrc;
|
Info.Header.biWidth := nWidthSrc;
|
||||||
@ -563,12 +562,12 @@ begin
|
|||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
// only get source data
|
// only get source data
|
||||||
SrcPixelBytes := SrcWinBmp.bmBitsPixel shr 3;
|
SrcPixelBytes := SrcSection.dsBm.bmBitsPixel shr 3;
|
||||||
if GetObject(SrcBmp, SizeOf(SrcSection), @SrcSection) <> 0
|
if SrcSection.dsBm.bmBits <> nil
|
||||||
then begin
|
then begin
|
||||||
// source is a dibsection :)
|
// source is a dibsection :)
|
||||||
SrcBytesPtr := SrcSection.dsBm.bmBits;
|
SrcBytesPtr := SrcSection.dsBm.bmBits;
|
||||||
SrcRowStride := SrcWinBmp.bmWidth * SrcPixelBytes;
|
SrcRowStride := SrcSection.dsBm.bmWidthBytes;
|
||||||
CleanupSrc := False;
|
CleanupSrc := False;
|
||||||
CleanupSrcPtr := False;
|
CleanupSrcPtr := False;
|
||||||
end
|
end
|
||||||
@ -586,8 +585,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// if a palette destination or destination isn't a section, create a temp DIB
|
// if a palette destination or destination isn't a section, create a temp DIB
|
||||||
if (DstWinBmp.bmBitsPixel < 24)
|
if (DstSection.dsBm.bmBitsPixel < 24)
|
||||||
or (GetObject(DstBmp, SizeOf(DstSection), @DstSection) = 0)
|
or (DstSection.dsBm.bmBits = nil)
|
||||||
or (DstSection.dsBmih.biCompression <> BI_RGB)
|
or (DstSection.dsBmih.biCompression <> BI_RGB)
|
||||||
then begin
|
then begin
|
||||||
// create temp dib
|
// create temp dib
|
||||||
@ -604,8 +603,8 @@ begin
|
|||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
DstBytesPtr := DstSection.dsBm.bmBits;
|
DstBytesPtr := DstSection.dsBm.bmBits;
|
||||||
DstPixelBytes := DstWinBmp.bmBitsPixel shr 3;
|
DstPixelBytes := DstSection.dsBm.bmBitsPixel shr 3;
|
||||||
DstRowStride := DstWinBmp.bmWidth * DstPixelBytes;
|
DstRowStride := DstSection.dsBm.bmWidthBytes;
|
||||||
Inc(PByte(DstBytesPtr), nXOriginDest + nYOriginDest * DstRowStride);
|
Inc(PByte(DstBytesPtr), nXOriginDest + nYOriginDest * DstRowStride);
|
||||||
CleanupDst := False;
|
CleanupDst := False;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user