Help understanding Printer and "trim" [message #467695] |
Fri, 03 February 2006 20:19 |
Steve Messages: 29 Registered: July 2009 |
Junior Member |
|
|
I am printing an image and am trying to understand the snippets of code I
see. For example:
// draw onto printer scaled appropriately
Point srcDPI = display.getDPI();
Point destDPI = printer.getDPI();
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
int leftMargin = destDPI.x + trim.x; // one inch from left side of paper
int topMargin = destDPI.y / 2 + trim.y; // one-half inch from top edge
of paper
Image destImage = new Image(printer, srcData);
GC destGC = new GC(printer);
if (printer.startPage()) {
destGC.drawImage(destImage, 0, 0, bounds.width, bounds.height,
leftMargin, topMargin, bounds.width*destDPI.x/ srcDPI.x,
bounds.height*destDPI.y/ srcDPI.y);
}
I understand all of this, except the trim values. How do they correspond to
margins? In my case:
destDPI.x = 600
destDPI.y = 600
trim.height = 217
trim.width = 217
trim.x = -108
trim.y = -108
I don't understand the destGC.drawImage() call. Specifically, why do you
set destX=leftMargin (492 in my case) and destY=topMargin (192 in my case).
Does this mean that my image will be drawn starting at 492,192 on the
printer GC? What is computeTrim really returning and why can't I use 0,0
for destX and destY?
Thanks,
Steve
|
|
|
Powered by
FUDForum. Page generated in 0.03398 seconds