#1 2016-01-28 18:14:29

alexeydott
Member
Registered: 2016-01-28
Posts: 1

small fix for TPdfEnum.PolyPoly procedure

EMR_POLYPOLYLINE and EMR_POLYPOLYLINE16 records in pdf file draws always closed like EMR_POLYPOLYGON or EMR_POLYPOLYGON16
below my fix for this problem

procedure TPdfEnum.PolyPoly(data: PEMRPolyPolygon; iType: Integer);
var i, j, PolyOffs, PolyFirst: DWord;
    pPolyPointsArray: PPointArray;
    pPolyPointsArray16: PSmallPointArray;
    data16: PEMRPolyPolygon16 absolute data;
begin
  NeedBrushAndPen;
  if not Canvas.FNewPath then
    Canvas.NewPath;
  case iType of
    EMR_POLYPOLYGON, EMR_POLYPOLYLINE: begin
      PolyOffs := 0;
      pPolyPointsArray := pointer(PtrUInt(data) + SizeOf(TEMRPolyPolyline)
        - SizeOf(TPoint) + (data^.nPolys - 1)*SizeOf(DWORD));
      for i := 1 to data^.nPolys do begin
        PolyFirst := PolyOffs;
        Canvas.MoveToI(pPolyPointsArray[PolyOffs].X, pPolyPointsArray[PolyOffs].Y);
        Inc(PolyOffs);
        for j := 2 to data^.aPolyCounts[i-1] do begin
          Canvas.LineToI(pPolyPointsArray[PolyOffs].X, pPolyPointsArray[PolyOffs].Y);
          DC[nDC].Position := Point(pPolyPointsArray[PolyOffs].X, pPolyPointsArray[PolyOffs].Y);
          Inc(PolyOffs);
        end;
///////////////////////////////////////////////////////
if iType = EMR_POLYPOLYGON then  //<-- add this line
///////////////////////////////////////////////////////
          Canvas.LineToI(pPolyPointsArray[PolyFirst].X, pPolyPointsArray[PolyFirst].Y);
        DC[nDC].Moved := false;
      end;
    end;
    EMR_POLYPOLYGON16, EMR_POLYPOLYLINE16: begin
      PolyOffs := 0;
      pPolyPointsArray16 := pointer(PtrUInt(data16) + SizeOf(TEMRPolyPolyline16)
        - SizeOf(TSmallPoint) + (data16^.nPolys - 1)*SizeOf(DWORD));
      for i := 1 to data16^.nPolys do begin
        PolyFirst := PolyOffs;
        Canvas.MoveToI(pPolyPointsArray16[PolyOffs].X, pPolyPointsArray16[PolyOffs].Y);
        Inc(PolyOffs);
        for j := 2 to data16^.aPolyCounts[i-1] do begin
          Canvas.LineToI(pPolyPointsArray16[PolyOffs].X, pPolyPointsArray16[PolyOffs].Y);
          DC[nDC].Position := Point(pPolyPointsArray16[PolyOffs].X, pPolyPointsArray16[PolyOffs].Y);
          Inc(PolyOffs);
        end;
///////////////////////////////////////////////////////
if iType = EMR_POLYPOLYGON16 then  //<-- add this line
///////////////////////////////////////////////////////
          Canvas.LineToI(pPolyPointsArray16[PolyFirst].X, pPolyPointsArray16[PolyFirst].Y);
        DC[nDC].Moved := false;
      end;
    end;
  end;

//...

before
35me6wm.png
after
9tpr3p.jpg

Last edited by alexeydott (2016-01-28 18:30:55)

Offline

Board footer

Powered by FluxBB