#1 2013-02-15 14:16:26

CoMPi
Member
Registered: 2013-02-14
Posts: 7

PolyDraw problem

Hi everyone.

Below is a copy of my post which was placed in 'SynPdf library 1.18' thread - wrong place, I think. So I copy it here.

First, I would like to thank you for you great work! Arnaud, I know that you had to spend a lot of time to develop such a great library.
Now, go back to my problem. I tried to create a pdf file using SynPDF and everything went great ... untill I used PolyDraw. It is crucial for me because the PolyDraw method is a base of my framework. So my question is: is it possible to use  the method in PDF files created by SyPDF? If so, how to do that? If not, are you going to implement the method in the near future?
Once again, thank you for your great work!

Piotr

Offline

#2 2013-02-15 15:05:49

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

Re: PolyDraw problem

EMR_POLYDRAW record is indeed not handled yet in function EnumEMFFunc() of SynPDF.

Please create a ticket to ask for this implementaiton.
http://synopse.info/fossil/reportlist

Offline

#3 2013-02-15 19:26:22

CoMPi
Member
Registered: 2013-02-14
Posts: 7

Re: PolyDraw problem

Here is my implementation of PolyDraw. As Arnaud wrote, the code must be put into EnumEMFFunc() function. I would like someone to check it out.

  EMR_POLYDRAW: begin
    if not pen.null then
      E.NeedPen;
    types := Pointer(Integer(@PEMRPolyDraw(R)^.aptl[0]) + PEMRPolyDraw(R)^.cptl * SizeOf(TPoint));
    i := 0;
    while i < PEMRPolyDraw(R)^.cptl do begin
      case types^[i] of
        PT_LINETO: E.Canvas.LineToI(PEMRPolyDraw(R)^.aptl[i].X,PEMRPolyDraw(R)^.aptl[i].Y);
        PT_BEZIERTO: begin
            E.Canvas.CurveToCI(PEMRPolyDraw(R)^.aptl[i+1].X,PEMRPolyDraw(R)^.aptl[i+1].Y,
              PEMRPolyDraw(R)^.aptl[i+2].X,PEMRPolyDraw(R)^.aptl[i+2].Y,
              PEMRPolyDraw(R)^.aptl[i+3].X,PEMRPolyDraw(R)^.aptl[i+3].Y);
            Inc(i, 3);
          end;
        PT_MOVETO: begin
            E.Canvas.MoveToI(PEMRPolyDraw(R)^.aptl[i].X,PEMRPolyDraw(R)^.aptl[i].Y);
            Moved := PEMRPolyDraw(R)^.aptl[i];
          end;
      else  // PT_CLOSEFIGURE
        E.Canvas.LineToI(PEMRPolyDraw(R)^.aptl[i].X,PEMRPolyDraw(R)^.aptl[i].Y);
        E.Canvas.LineToI(Moved.X, Moved.Y);
        Moved := PEMRPolyDraw(R)^.aptl[i];
      end;
      Inc(i);
    end;
    Moved := PEMRPolyDraw(R)^.aptl[PEMRPolyDraw(R)^.cptl - 1];
    if not E.Canvas.FNewPath then
      if not pen.null then
        E.Canvas.Stroke else
        E.Canvas.NewPath;
  end;

  EMR_POLYDRAW16: begin
    if not pen.null then
      E.NeedPen;
    types := Pointer(Integer(@PEMRPolyDraw16(R)^.apts[0]) + PEMRPolyDraw16(R)^.cpts * SizeOf(TSmallPoint));
    i := 0;
    while i < PEMRPolyDraw16(R)^.cpts do begin
      case types^[i] of
        PT_LINETO: E.Canvas.LineToI(PEMRPolyDraw16(R)^.apts[i].X,PEMRPolyDraw16(R)^.apts[i].Y);
        PT_BEZIERTO: begin
            E.Canvas.CurveToCI(PEMRPolyDraw16(R)^.apts[i+1].X,PEMRPolyDraw16(R)^.apts[i+1].Y,
              PEMRPolyDraw16(R)^.apts[i+2].X,PEMRPolyDraw16(R)^.apts[i+2].Y,
              PEMRPolyDraw16(R)^.apts[i+3].X,PEMRPolyDraw16(R)^.apts[i+3].Y);
            Inc(i, 2);
          end;
        PT_MOVETO: begin
            E.Canvas.MoveToI(PEMRPolyDraw16(R)^.apts[i].X,PEMRPolyDraw16(R)^.apts[i].Y);
            Moved := Point(PEMRPolyDraw16(R)^.apts[i].X, PEMRPolyDraw16(R)^.apts[i].Y);
          end;
      else  // PT_CLOSEFIGURE
        E.Canvas.LineToI(PEMRPolyDraw16(R)^.apts[i].X,PEMRPolyDraw16(R)^.apts[i].Y);
        E.Canvas.LineToI(Moved.X, Moved.Y);
        Moved := Point(PEMRPolyDraw16(R)^.apts[i].X, PEMRPolyDraw16(R)^.apts[i].Y);
      end;
      Inc(i);
    end;
    Moved := Point(PEMRPolyDraw16(R)^.apts[PEMRPolyDraw16(R)^.cpts - 1].X, PEMRPolyDraw16(R)^.apts[PEMRPolyDraw16(R)^.cpts - 1].Y);
    if not E.Canvas.FNewPath then
      if not pen.null then
        E.Canvas.Stroke else
        E.Canvas.NewPath;
  end;

Offline

#4 2013-02-16 16:26:20

CoMPi
Member
Registered: 2013-02-14
Posts: 7

Re: PolyDraw problem

Is there really no one who could check it out?

Offline

#5 2013-02-16 18:30:42

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

Re: PolyDraw problem

This looks fine, but I suspect the types can be combined with OR so a case switch is perharps not correct.

I will check tomorow.

Thanks for the great input.

Offline

#6 2013-02-17 08:51:57

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

Re: PolyDraw problem

I've added EMR_POLYDRAW, EMR_POLYDRAW16 process, including ORed PT_CLOSEFIGURE types, as stated by http://msdn.microsoft.com/en-us/library … p/dd162813

See http://synopse.info/fossil/info/7fc4114b79

Offline

Board footer

Powered by FluxBB