Landscape orientation with image very slow

30 views
Skip to first unread message

Barnie

unread,
Mar 17, 2011, 12:47:42 PM3/17/11
to SWT PaperClips
Hi,

i want to print an image (4000 x 2000 pixel) in landscape format.

ImageLoader imageLoader = new ImageLoader();
ImageData[] imageData = imageLoader.load("path_to_image.jpg");
ImagePrint imagePrint = new ImagePrint(imageData[0]);

The simple solution with
printJob.setOrientation(PaperClips.ORIENTATION_LANDSCAPE) gives me the
right result, but is very slow (I have to wait 3-4 minutes after
sending the print job to the printer). Same when dealing with
RotatePrint(). Why is this so? I assume the image rotation is complex.

For a better performance i am now rotating the ImageData (SWT) before
creating the ImagePrint (PaperClips).

ImageLoader imageLoader = new ImageLoader();
ImageData[] imageData = imageLoader.load("path_to_image.jpg");
ImageData rotatedImageData = rotate(imageData[0]);
ImagePrint imagePrint = new ImagePrint(rotatedImageData);

This works very fine and without delay, and I do not need to set the
orientation of the print job. But My problem is now to scale this
rotated image to take all available space of the document. I have to
fill all vertical space, then i could print the document in default
orientation.

Thanks in advance for any advice.
Barnie

Matthew Hall

unread,
Apr 11, 2012, 3:54:29 PM4/11/12
to swt-pap...@googlegroups.com
Rotation using RotatePrint or ORIENTATION_LANDSCAPE is achieved using the SWT GC.setTransform API. Apparently rotating a large image as in your case incurs a very large penalty.

By rotating the image data yourself, it seems you removed the need for PaperClips to set a transform, and thus avoided the performance penalty.

I will add something to the FAQ so users can be aware of this.

-Matthew
Reply all
Reply to author
Forward
0 new messages