Re: [JAVA2D] Print BufferedImage Externally Generated

2008-11-26 Thread Phil Race
The clipping is because the imageable area of the paper may be less than 
the physical size of the paper.
You need to get the imageable area from the PageFormat and then scale 
your rendering (ie the final image) to fit.
You can also control this by specifying the imageable area in the 
PageFormat but you'll need to use the javax.print

APIs to find out what is the hard liimit for the device
See 
http://java.sun.com/javase/6/docs/api/javax/print/attribute/standard/MediaPrintableArea.html


But
>I'm trying to build up a BufferedImage using its Graphics component, 
and then print that image using a Printable

Why? As in I don't know why you aren't rendering directly to the printer ?

If you do what you are doing you will get blocky output, unless you 
create a very large image and scale
it to printer resolutions. Even then it means you won't get printer 
fonts etc.


So I suspect your approach is costing you in
- output quality
- memory used
- performance

-phil.

[EMAIL PROTECTED] wrote:

Hi, I'm trying to build up a BufferedImage using its Graphics component, and 
then print that image using a Printable.  The problem is that some of my 
operations on the graphics component seem to be lost, and when I print the 
image, a lot of it is clipped off around the borders.  The code below shows the 
gist of what I'm doing.

// this method is in class A
foo(String text, Font font, B b, int x, int y) {
  Graphics2D g2d = (Graphics2D) image.getGraphics();
  g2d.setColor(Color.black);  // this color gets lost when bar is called
  g2d.setFont(font); // this font gets lost when bar is called
  b.bar(text, x, y);
}

// this method is in class B
bar(String text, int x, int y) {
  Graphics2D g2d = (Graphics2D) image.getGraphics();
  g2d.drawString(text, x, y); // this does not get lost when the image is 
printed
}

// this is the print method for the Printable, the image is passed to the 
Printable
print(Graphics g, PageFormat pf, int pageIndex) {
  if (pageIndex == 0) {
Graphics2D g2d = (Graphics2D)image.getGraphics();
g2d.translate(pf.getImageableX(), pf.getImageableY());
((Graphics2D)graphics).drawImage(image, null, 0, 0);
return Printable.PAGE_EXISTS;
  } else {
return Printable.NO_SUCH_PAGE;
  }
}


If I hardcode the color and font in the bar method, then the text actually comes out at the 
printer, but if x < 80 or x > 500, it doesn't get printed; same if y < 80 or y 
> 600 (these are approximate, I'm just estimating based on what I printed and where it 
got cut off).  This leaves about a 1 inch margin around the printed text on the paper from 
the printer.  Ultimately, I want to generate a document image using j2d and send that to 
the printer.  Any help is greatly appreciated!

Thanks in advance!
[Message sent by forum member 'wtrpirate' (wtrpirate)]

http://forums.java.net/jive/thread.jspa?messageID=318909

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
  


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


[JAVA2D] Print BufferedImage Externally Generated

2008-11-26 Thread java2d
Hi, I'm trying to build up a BufferedImage using its Graphics component, and 
then print that image using a Printable.  The problem is that some of my 
operations on the graphics component seem to be lost, and when I print the 
image, a lot of it is clipped off around the borders.  The code below shows the 
gist of what I'm doing.

// this method is in class A
foo(String text, Font font, B b, int x, int y) {
  Graphics2D g2d = (Graphics2D) image.getGraphics();
  g2d.setColor(Color.black);  // this color gets lost when bar is called
  g2d.setFont(font); // this font gets lost when bar is called
  b.bar(text, x, y);
}

// this method is in class B
bar(String text, int x, int y) {
  Graphics2D g2d = (Graphics2D) image.getGraphics();
  g2d.drawString(text, x, y); // this does not get lost when the image is 
printed
}

// this is the print method for the Printable, the image is passed to the 
Printable
print(Graphics g, PageFormat pf, int pageIndex) {
  if (pageIndex == 0) {
Graphics2D g2d = (Graphics2D)image.getGraphics();
g2d.translate(pf.getImageableX(), pf.getImageableY());
((Graphics2D)graphics).drawImage(image, null, 0, 0);
return Printable.PAGE_EXISTS;
  } else {
return Printable.NO_SUCH_PAGE;
  }
}


If I hardcode the color and font in the bar method, then the text actually 
comes out at the printer, but if x < 80 or x > 500, it doesn't get printed; 
same if y < 80 or y > 600 (these are approximate, I'm just estimating based on 
what I printed and where it got cut off).  This leaves about a 1 inch margin 
around the printed text on the paper from the printer.  Ultimately, I want to 
generate a document image using j2d and send that to the printer.  Any help is 
greatly appreciated!

Thanks in advance!
[Message sent by forum member 'wtrpirate' (wtrpirate)]

http://forums.java.net/jive/thread.jspa?messageID=318909

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Poor performance of Java2D

2008-11-26 Thread java2d
I have only recently found your results from "Swing links of the week" ))

I have run this benchmark on Ubuntu 8.10 and the results are rather strange: 
only OpenGL pipelines allowed to increase performance for both Qt and Java2D. 
And even Qt pure software rendering is slower then in WinXP with MinGW 
compiler. Probably something wrong with blitting images in drivers.
[Message sent by forum member 'kamre' (kamre)]

http://forums.java.net/jive/thread.jspa?messageID=318906

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Poor performance of Java2D

2008-11-26 Thread Dmitri Trembovetski

  One other minor thing I've noticed: in Renderer.paint
  move the setting of the AA hint to after fillRect call which
  fills the bg. No need to have AA set when filling the
  background.

  Won't help a whole lot though.

  Thanks,
Dmitri


[EMAIL PROTECTED] wrote:

Jim, thank you for anwsers.

By the way I have slightly improved performance by turning off antialiasing for 
fill operation if it is followed by draw operation for the same path. It seems 
that there is no sense to antialias fill in such cases. Also some correction 
for computation of bounds of gradient was made in order to better correspond to 
Qt version. Results are here: http://trac-hg.assembla.com/jgears/wiki#Java2D
[Message sent by forum member 'kamre' (kamre)]

http://forums.java.net/jive/thread.jspa?messageID=318756

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Poor performance of Java2D

2008-11-26 Thread Ken Warner

Nice job.  Worked on my Win2K box with no native acceleration.
Java 6u10.  Got about 14-15 fps anti-alias -- 24-25 fps not.

Noticed that when Gears is iconified it continues to run
at full throttle taking 100% of my CPU.

[EMAIL PROTECTED] wrote:

*laughing*
Just did the same thing a month ago: 
http://linuxhippy.blogspot.com/2008/11/jgears2-rendermark.html
[Message sent by forum member 'linuxhippy' (linuxhippy)]

http://forums.java.net/jive/thread.jspa?messageID=318832

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


Re: [JAVA2D] Poor performance of Java2D

2008-11-26 Thread java2d
*laughing*
Just did the same thing a month ago: 
http://linuxhippy.blogspot.com/2008/11/jgears2-rendermark.html
[Message sent by forum member 'linuxhippy' (linuxhippy)]

http://forums.java.net/jive/thread.jspa?messageID=318832

===
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".