#1 2013-03-06 06:53:19

Chaa
Member
Registered: 2011-03-26
Posts: 245

Several fixes in RenderMetaFile

Several fixes in RenderMetaFile:

  1. Added fNewPath := False to TPdfCanvas.DrawXObjectEx. Without this code, lines after the image is not drawn correctly.

    procedure TPdfCanvas.DrawXObjectEx(X, Y, AWidth, AHeight: Single;
          ClipX, ClipY, ClipWidth, ClipHeight: Single; const AXObjectName: PDFString);
    begin
      DrawXObjectPrepare(AXObjectName);
      GSave;
      Rectangle(ClipX, ClipY, ClipWidth, ClipHeight);
      Clip;
      NewPath;
      fNewPath := False;
      ConcatToCTM(AWidth, 0, 0, AHeight, X, Y);
      ExecuteXObject(AXObjectName);
      GRestore;
    end;
  2. Added EMR_TRANSPARENTBLT and setting "Color Key Masking" attribute for image. Perhaps it should be done more accurately. PDF spec is not clear about how to do this for 8-bit images.

  3. Added hack to mirror image when WorldTransform.eM22 has negative value, i.e. "Vertical reflection component" in http://msdn.microsoft.com/en-us/library … s.85).aspx

    EMR_STRETCHDIBITS:
      with PEMRStretchDIBits(R)^ do // only handle RGB bitmaps (no palette)
        if (offBmiSrc<>0) and (offBitsSrc<>0) then begin
          if WorldTransform.eM22 < 0 then
            with PBitmapInfo(PtrUInt(R)+offBmiSrc)^ do
              bmiHeader.biHeight := -bmiHeader.biHeight;

    There also may be "Horizontal reflection component" in WorldTransform.eM11. Reflection can be done by changing sign of image width or height parameter in StretchDIBits call.

Source code and images.

Offline

#2 2013-03-06 07:42:57

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Several fixes in RenderMetaFile

I've added those enhancements.
See http://synopse.info/fossil/info/c1b5c0772a

Thanks!

Online

Board footer

Powered by FluxBB