#1 2013-04-19 09:06:03

kalwados
Member
Registered: 2011-04-18
Posts: 15

PDF file looks different using SynPDF V1.18: vertical mirrored images

Hello *,

After upgrading from SynPDF v1.15 to the latest version v1.18 my PDFs looks different: Some images are no longer flipped (or mirrored) as they used to be in the older version.

In detail:
I'm using QuickReport; and I use TPdfDocumentGDI to render QuickReport's pages (which are Windows EMF) into PDF. Some parts of this Metafiles are images (bitmaps), which need to be mirrored on the vertical axis to create a "left hand" and "right hand" look. I create those mirrored bitmaps by swapping left and right coordinates; which looks OK on display, in the print preview and on printer output (paper).
It also used to be OK with older SynPDF version, but after installing latest v1.18, those images are no longer mirrored in the PDF!

So what has been changed in SynPDF?
Perhaps the better question: How could I create a vertical mirrored bitmap which will look as intended in the PDF?

Screenshots of PDF in Adobe Reader X:
https://dl.dropboxusercontent.com/u/562 … _v1-15.jpg
https://dl.dropboxusercontent.com/u/562 … _v1-18.jpg

TIA
Kalwados.

Last edited by kalwados (2013-04-19 09:15:24)

Offline

#2 2013-04-19 11:27:32

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

Re: PDF file looks different using SynPDF V1.18: vertical mirrored images

A lot of changes did happen between the 1.15 and the 1.18.
Please see the history in the beginning of the unit, or http://synopse.info/fossil/finfo?name=SynPdf.pas

We will need some .emf file to reproduce the problem.

Some fixes were introduced about bitmap rendering, perhaps there is a regression here.

Offline

#3 2013-04-19 13:02:01

kalwados
Member
Registered: 2011-04-18
Posts: 15

Re: PDF file looks different using SynPDF V1.18: vertical mirrored images

Hello AB,

I'll will provide some EMF files for testing soon.

Offline

#4 2013-09-04 08:23:15

kalwados
Member
Registered: 2011-04-18
Posts: 15

Re: PDF file looks different using SynPDF V1.18: vertical mirrored images

Hello,

I finally found some time to analyze this problem:

In SynPDF V1.18 there was a small code change in function TPdfCanvas.RectI(): The call to NormalizeRect() was moved from top to bottom of that function:

http://synopse.info/fossil/info/2bb4d7686e

Old:

  function TPdfCanvas.RectI(Rect: TRect): TPdfRect; TPdfRect;
  begin 
    NormalizeRect(Rect);          <<<<<<<<<<
    result.Left := I2X(Rect.Left);
    result.Right := I2X(Rect.Right); 
    result.Top := I2Y(Rect.Bottom); 
    result.Bottom := I2Y(Rect.Top);
  end;                                          

New:

  function TPdfCanvas.RectI(Rect: TRect): TPdfRect; TPdfRect;
  begin 
    result.Left := I2X(Rect.Left);
    result.Right := I2X(Rect.Right); 
    result.Top := I2Y(Rect.Bottom); 
    result.Bottom := I2Y(Rect.Top);
    NormalizeRect(Rect);          <<<<<<<<<<
  end;                                          

The call to NormalizeRect() was moved from the first line to the last line of the code, causing my mirrored bitmaps to appear non-mirrored. If I change this function back to the older version, my PDF files look OK again.

But I think there was some very good reason to change the behaviour of TPdfCanvas.RectI(), however I do not know that reason.

Here is a sample EMF file which I used for testing:
https://dl.dropboxusercontent.com/u/562 … bitmap.emf

Is reverting the code of TPdfCanvas.RectI() back to version 1.17 the correct solution?

TIA
Kalwados

Offline

#5 2013-09-04 11:01:49

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

Re: PDF file looks different using SynPDF V1.18: vertical mirrored images

NormalizeRect(Rect) does not make sense, but this is not the new code:

function TPdfCanvas.RectI(Rect: TRect): TPdfRect;
begin
  result.Left := I2X(Rect.Left);
  result.Right := I2X(Rect.Right);
  result.Top := I2Y(Rect.Top);
  result.Bottom := I2Y(Rect.Bottom);
  NormalizeRect(result);
end;

This code sounds just fine, doesn't it?

Offline

#6 2013-09-04 11:19:58

kalwados
Member
Registered: 2011-04-18
Posts: 15

Re: PDF file looks different using SynPDF V1.18: vertical mirrored images

Sorry, copy & paste error :-(
The new code is indeed using

NormalizeRect(result);

but that doesn't explain why the old code works fine, while the new code doesn't.

Any ideas how to solve that problem?

Offline

#7 2013-09-04 11:50:43

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

Re: PDF file looks different using SynPDF V1.18: vertical mirrored images

I suspect this is because the coordinate system is not oriented the same.

We went back to the previous code... until further notice.
See http://synopse.info/fossil/info/2e9c437afd

Thanks for the feedback.

Offline

#8 2013-09-04 12:22:06

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

Re: PDF file looks different using SynPDF V1.18: vertical mirrored images

I've a failing .emf file here from our regression tests...

I was not able to find a solution for both of them.
See http://synopse.info/fossil/info/3246866b44

But with this commit, the mirrored file is not working.
Any idea?

Offline

Board footer

Powered by FluxBB