Skip to content

Commit 26afa29

Browse files
author
Arnaud Bouchez
committed
pdf: enhanced meta-file rendering
- added EMR_ALPHABLEND basic support from https://synopse.info/forum/viewtopic.php?pid=43616#p43616 - simplified code thanks to (despite?) "with" context
1 parent 838a132 commit 26afa29

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.3.10709'
1+
'2.3.10710'

src/ui/mormot.ui.pdf.pas

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10436,7 +10436,7 @@ function CenterPoint(const Rect: TRect): TPoint;
1043610436
function EnumEMFFunc(DC: HDC; var Table: THandleTable; R: PEnhMetaRecord;
1043710437
NumObjects: DWord; E: TPdfEnum): LongBool; stdcall;
1043810438
var
10439-
i: integer;
10439+
i: PtrInt;
1044010440
InitTransX: XForm;
1044110441
polytypes: PByteArray;
1044210442
begin
@@ -10975,37 +10975,29 @@ function EnumEMFFunc(DC: HDC; var Table: THandleTable; R: PEnhMetaRecord;
1097510975
with PEMRBitBlt(R)^ do // only handle RGB bitmaps (no palette)
1097610976
if (offBmiSrc <> 0) and
1097710977
(offBitsSrc <> 0) then
10978-
begin
1097910978
E.DrawBitmap(xSrc, ySrc, cxDest, cyDest, xDest, yDest,
1098010979
cxDest, cyDest, iUsageSrc, pointer(PtrUInt(R) + offBmiSrc),
10981-
pointer(PtrUInt(R) + offBitsSrc), @PEMRBitBlt(R)^.rclBounds,
10982-
@PEMRBitBlt(R)^.xformSrc, PEMRBitBlt(R)^.dwRop);
10983-
end
10980+
pointer(PtrUInt(R) + offBitsSrc), @rclBounds, @xformSrc, dwRop)
1098410981
else
10985-
case PEMRBitBlt(R)^.dwRop of // we only handle PATCOPY = fillrect
10982+
case dwRop of // we only handle PATCOPY = fillrect
1098610983
PATCOPY:
10987-
with PEMRBitBlt(R)^ do
10988-
E.FillRectangle(Rect(xDest, yDest,
10989-
xDest + cxDest, yDest + cyDest), true);
10984+
E.FillRectangle(Rect(xDest, yDest,
10985+
xDest + cxDest, yDest + cyDest), true);
1099010986
end;
1099110987
end;
1099210988
EMR_STRETCHBLT:
1099310989
begin
1099410990
with PEMRStretchBlt(R)^ do // only handle RGB bitmaps (no palette)
1099510991
if (offBmiSrc <> 0) and
1099610992
(offBitsSrc <> 0) then
10997-
begin
1099810993
E.DrawBitmap(xSrc, ySrc, cxSrc, cySrc, xDest, yDest, cxDest,
1099910994
cyDest, iUsageSrc, pointer(PtrUInt(R) + offBmiSrc),
11000-
pointer(PtrUInt(R) + offBitsSrc), @PEMRStretchBlt(R)^.rclBounds,
11001-
@PEMRStretchBlt(R)^.xformSrc, PEMRStretchBlt(R)^.dwRop);
11002-
end
10995+
pointer(PtrUInt(R) + offBitsSrc), @rclBounds, @xformSrc, dwRop)
1100310996
else
11004-
case PEMRStretchBlt(R)^.dwRop of // we only handle PATCOPY = fillrect
10997+
case dwRop of // we only handle PATCOPY = fillrect
1100510998
PATCOPY:
11006-
with PEMRStretchBlt(R)^ do
11007-
E.FillRectangle(Rect(
11008-
xDest, yDest, xDest + cxDest, yDest + cyDest), true);
10999+
E.FillRectangle(Rect(
11000+
xDest, yDest, xDest + cxDest, yDest + cyDest), true);
1100911001
end;
1101011002
end;
1101111003
EMR_STRETCHDIBITS:
@@ -11018,26 +11010,37 @@ function EnumEMFFunc(DC: HDC; var Table: THandleTable; R: PEnhMetaRecord;
1101811010
bmiHeader.biHeight := -bmiHeader.biHeight;
1101911011
E.DrawBitmap(xSrc, ySrc, cxSrc, cySrc, xDest, yDest, cxDest, cyDest,
1102011012
iUsageSrc, pointer(PtrUInt(R) + offBmiSrc),
11021-
pointer(PtrUInt(R) + offBitsSrc), @PEMRStretchDIBits(R)^.rclBounds,
11022-
nil, PEMRStretchDIBits(R)^.dwRop);
11013+
pointer(PtrUInt(R) + offBitsSrc), @rclBounds, nil, dwRop);
1102311014
end;
1102411015
EMR_TRANSPARENTBLT:
1102511016
with PEMRTransparentBLT(R)^ do // only handle RGB bitmaps (no palette)
1102611017
if (offBmiSrc <> 0) and
1102711018
(offBitsSrc <> 0) then
1102811019
E.DrawBitmap(xSrc, ySrc, cxSrc, cySrc, xDest, yDest, cxDest, cyDest,
1102911020
iUsageSrc, pointer(PtrUInt(R) + offBmiSrc),
11030-
pointer(PtrUInt(R) + offBitsSrc), @PEMRTransparentBLT(R)^.rclBounds,
11031-
@PEMRTransparentBLT(R)^.xformSrc, SRCCOPY,
11032-
PEMRTransparentBLT(R)^.dwRop); // dwRop stores the transparent color
11021+
pointer(PtrUInt(R) + offBitsSrc), @rclBounds, @xformSrc, SRCCOPY,
11022+
dwRop); // dwRop stores the transparent color
11023+
EMR_ALPHABLEND:
11024+
with PEMRAlphaBlend(R)^ do // only handle RGB bitmaps (no palette nor transparency)
11025+
if (offBmiSrc <> 0) and
11026+
(offBitsSrc <> 0) then
11027+
E.DrawBitmap (xSrc, ySrc, cxSrc, cySrc, xDest, yDest, cxDest, cyDest,
11028+
iUsageSrc, pointer(PtrUInt(R) + offBmiSrc), pointer(
11029+
PtrUInt(R) + offBitsSrc), @rclBounds, @xformSrc, SRCCOPY, dwRop)
11030+
else
11031+
case dwRop of // we only handle PATCOPY = fillrect
11032+
PATCOPY:
11033+
E.FillRectangle(Rect(xDest, yDest,
11034+
xDest + cxDest, yDest + cyDest), true);
11035+
end;
1103311036
EMR_GDICOMMENT:
11034-
with PEMRGDICOMMENT(R)^ do
11037+
with PEMRGDIComment(R)^ do
1103511038
if cbData >= 1 then
1103611039
E.HandleComment(
1103711040
TPdfGdiComment(Data[0]), PAnsiChar(@Data) + 1, cbData - 1);
1103811041
EMR_MODIFYWORLDTRANSFORM:
1103911042
with PEMRModifyWorldTransform(R)^ do
11040-
E.ScaleMatrix(@PEMRModifyWorldTransform(R)^.xform, iMode);
11043+
E.ScaleMatrix(@xform, iMode);
1104111044
EMR_EXTCREATEPEN: // approx. - fast solution
1104211045
with PEMRExtCreatePen(R)^ do
1104311046
if ihPen - 1 < cardinal(length(E.Obj)) then

0 commit comments

Comments
 (0)