#6 Scaled rendering of images does not work

open
nobody
None
5
2004-08-09
2004-08-09
Anonymous
No

I believe the method PDFGraphics.drawImage(Image
img,int x,int y,int w,int h, ImageObserver obs) has an
error with writing out the PDF code

I think w and h are supposed to be width and height in
the PDF's coordinate System (with 72 dpi), but these
parameters are completely ignored:

// q w 0 0 h x y cm % the coordinate matrix
pw.print("q " +
image.getWidth() +
" 0 0 " +
image.getHeight() +
" " + x + " " +
((int)page.getDimension().getHeight()-y-image.getHeight())
+
" cm \n" + image.getName() + " Do\nQ\n");

The comment is correct, the transformation matrix is [
q w 0 0 h x y ], but the w and h are the image's actual
width and height, thus it doesn't get scaled

I think the code should be:

pw.print("q " +
w +
" 0 0 " +
h +
" " + x + " " +
((int)page.getDimension().getHeight()-y-h) +
" cm \n" + image.getName() + " Do\nQ\n");

At least then it behaves as I expect it to ;-)

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks