Bug 691830

Summary: matrix accuracy problem
Product: GhostPCL Reporter: norbert.janssen
Component: PCL rasterAssignee: Henry Stiles <henry.stiles>
Status: NOTIFIED LATER    
Severity: normal    
Priority: P2    
Version: master   
Hardware: PC   
OS: Windows XP   
Customer: 661 Word Size: ---

Description norbert.janssen 2010-12-10 13:12:36 UTC
In pximage.c (pxBeginImage()) there is some code which calculates the ImageMatrix.

          gs_matrix_invert(&dmat, &dmat);
          gs_matrix_multiply(&dmat, &imat, &pxenum->image.ImageMatrix);

I found a little problem with this (at least when compiled with MSVC, don't know for CYGWIN/gcc).
          the ImageMatrix.tx/ty should be same as dmat.tx/ty but there is a very minor difference due to using float math i.s.o. double math.

And needed to use the following to solve this.

          gs_matrix_double ddmat,dimat;

	  gs_matrix_invert_to_double(&dmat, &ddmat);
	  gs_matrix_multiply_double(&ddmat, &imat, &dimat);
	  pxenum->image.ImageMatrix.xx = (float)dimat.xx;
	  pxenum->image.ImageMatrix.yx = (float)dimat.yx;
	  pxenum->image.ImageMatrix.xy = (float)dimat.xy;
	  pxenum->image.ImageMatrix.yy = (float)dimat.yy;
	  pxenum->image.ImageMatrix.tx = (float)dimat.tx;
	  pxenum->image.ImageMatrix.ty = (float)dimat.ty;

Usage of invert_double + multiply_double is also used in gxipixel.c gx_image_enum_begin() function.

Seems logical to have better accuracy for this combination. Perhaps make a new method in gsmatrix.c for this?
Comment 1 Henry Stiles 2011-02-24 15:40:37 UTC
We really do want single precision here to be consistent with the graphics library, Invert/Multiply used in gxipixel.c is exactly what is needed for Postscript and PDF images and it must be done in single precision to be compatible with Adobe.  Also, I haven't seen the need for doubles on HP printers but the PCL specification is less clear on required precision.  Maybe we can find another solution if you can attach the file that prompted the change.