If the orientation is landscape the printing implementation is going
to apply a rotation for you , and you should notice this as the width and
height of the page format being swapped.
So you don't need to do the rotate yourself although you will want to
be aware of the different imageable area.
I guess one of these operations lost your image but its hard to say which
(although I don't remember any landscape printing problems on linux)
I believe the JAI transpose operator will do the rotation around the centre
of the image, so I am not sure that you've simply rotated your image
off the page, although that's worth checking out and verifying.
But given that you don't need to apply *both* of these rotations you
could try just one at a time and see which one causes the problem (and
you may be able to just do without the one that is the problem).
-phil.
> Date: Wed, 26 Sep 2001 16:43:13 -0400
> From: Thad Humphries <[EMAIL PROTECTED]>
> Subject: [JAVA2D] Printing Landscape
> To: [EMAIL PROTECTED]
>
> I have a program that prints an image fine when I print in portrait mode
> but come out blank (all white, all 0xFFFF) in landscape. I am using
> transpose to rotate the image for landscape. The code is below. I'm
> using JDK 1.3.1 on RedHat 6.2. Any ideas? Isn't "transpose" how I want
> to flip it?
>
> public class ImagePrinter implements Printable
> {
> RenderedOp image;
> RenderedOp rendered_image;
> JAIFrame myFrame;
>
> /** Creates new ImagePrinter */
> public ImagePrinter (
> JAIFrame frame )
> {
> this.myFrame = frame;
> }
>
>
> /**
> Displays the page setup and print dialogs and prints the
> image.
> */
> public void doPrinting()
> {
> PrinterJob job = PrinterJob.getPrinterJob();
> Book book = new Book();
>
> PageFormat defaultPageFmt = job.defaultPage();
> PageFormat pf = job.pageDialog( defaultPageFmt );
>
> // Cancel was pressed.
> if ( pf.equals( defaultPageFmt ) )
> {
> return;
> }
>
> book.append( this, pf );
> job.setPageable( book );
>
> if ( !job.printDialog() )
> {
> return;
> }
>
> if ( pf.getOrientation() == pf.LANDSCAPE )
> {
> // Rotate the image.
> ParameterBlock pbTrans = new ParameterBlock();
> pbTrans.addSource( myFrame.getRenderedOpImage() );
> pbTrans.add( TransposeDescriptor.ROTATE_270 );
> image = JAI.create( "transpose", pbTrans, null );
> }
> else
> {
> image = myFrame.getRenderedOpImage();
> }
>
> // Make sure not to print in the margin.
> Interpolation interp = Interpolation.getInstance(
> Interpolation.INTERP_NEAREST );
> ParameterBlock pb = new ParameterBlock();
> pb.addSource( image );
> pb.add( (float)pf.getImageableX() );
> pb.add( (float)pf.getImageableY() );
> pb.add( interp );
> rendered_image = (RenderedOp)JAI.create( "translate", pb, null
> );
>
> try
> {
> job.print();
> }
> catch ( PrinterException e )
> {
> e.printStackTrace();
> }
>
> }
>
>
> public int print (
> Graphics g,
> PageFormat pf,
> int pi )
> throws PrinterException
> {
> if ( pi != 0 )
> return NO_SUCH_PAGE;
>
> Graphics2D g2 = (Graphics2D)g;
>
> g2.drawRenderedImage( rendered_image, new AffineTransform() );
> System.gc();
>
> return PAGE_EXISTS;
> }
> }
>
> --
> -------------------------------------------------------------------------
> Thad Humphries "...no religious test shall ever be
> required
> Web Development Manager as a qualification to any office or public
> Phone: 540/675-3015, x225 trust under the United States." -Article
> VI
>
> ===========================================================================
> 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".