sun.print.ProxyGraphics2D Java Examples

The following examples show how to use sun.print.ProxyGraphics2D. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WPathGraphics.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #2
Source File: WPathGraphics.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #3
Source File: WPathGraphics.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #4
Source File: WPathGraphics.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #5
Source File: WPathGraphics.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #6
Source File: WPathGraphics.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by {@code region}.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #7
Source File: WPathGraphics.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #8
Source File: WPathGraphics.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #9
Source File: WPathGraphics.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    deviceClip(savedClip.getPathIterator(savedTransform));

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #10
Source File: WPathGraphics.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    deviceClip(savedClip.getPathIterator(savedTransform));

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #11
Source File: WPathGraphics.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #12
Source File: WPathGraphics.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}
 
Example #13
Source File: WPathGraphics.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Have the printing application redraw everything that falls
 * within the page bounds defined by <code>region</code>.
 */
@Override
public void redrawRegion(Rectangle2D region, double scaleX, double scaleY,
                         Shape savedClip, AffineTransform savedTransform)
        throws PrinterException {

    WPrinterJob wPrinterJob = (WPrinterJob)getPrinterJob();
    Printable painter = getPrintable();
    PageFormat pageFormat = getPageFormat();
    int pageIndex = getPageIndex();

    /* Create a buffered image big enough to hold the portion
     * of the source image being printed.
     */
    BufferedImage deepImage = new BufferedImage(
                                    (int) region.getWidth(),
                                    (int) region.getHeight(),
                                    BufferedImage.TYPE_3BYTE_BGR);

    /* Get a graphics for the application to render into.
     * We initialize the buffer to white in order to
     * match the paper and then we shift the BufferedImage
     * so that it covers the area on the page where the
     * caller's Image will be drawn.
     */
    Graphics2D g = deepImage.createGraphics();
    ProxyGraphics2D proxy = new ProxyGraphics2D(g, wPrinterJob);
    proxy.setColor(Color.white);
    proxy.fillRect(0, 0, deepImage.getWidth(), deepImage.getHeight());
    proxy.clipRect(0, 0, deepImage.getWidth(), deepImage.getHeight());

    proxy.translate(-region.getX(), -region.getY());

    /* Calculate the resolution of the source image.
     */
    float sourceResX = (float)(wPrinterJob.getXRes() / scaleX);
    float sourceResY = (float)(wPrinterJob.getYRes() / scaleY);

    /* The application expects to see user space at 72 dpi.
     * so change user space from image source resolution to
     *  72 dpi.
     */
    proxy.scale(sourceResX / DEFAULT_USER_RES,
                sourceResY / DEFAULT_USER_RES);

    proxy.translate(
        -wPrinterJob.getPhysicalPrintableX(pageFormat.getPaper())
           / wPrinterJob.getXRes() * DEFAULT_USER_RES,
        -wPrinterJob.getPhysicalPrintableY(pageFormat.getPaper())
           / wPrinterJob.getYRes() * DEFAULT_USER_RES);
    /* NB User space now has to be at 72 dpi for this calc to be correct */
    proxy.transform(new AffineTransform(getPageFormat().getMatrix()));
    proxy.setPaint(Color.black);

    painter.print(proxy, pageFormat, pageIndex);

    g.dispose();

    /* We need to set the device clip using saved information.
     * savedClip intersects the user clip with a clip that restricts
     * the GDI rendered area of our BufferedImage to that which
     * may correspond to a rotate or shear.
     * The saved device transform is needed as the current transform
     * is not likely to be the same.
     */
    if (savedClip != null) {
        deviceClip(savedClip.getPathIterator(savedTransform));
    }

    /* Scale the bounding rectangle by the scale transform.
     * Because the scaling transform has only x and y
     * scaling components it is equivalent to multiplying
     * the x components of the bounding rectangle by
     * the x scaling factor and to multiplying the y components
     * by the y scaling factor.
     */
    Rectangle2D.Float scaledBounds
            = new Rectangle2D.Float(
                    (float) (region.getX() * scaleX),
                    (float) (region.getY() * scaleY),
                    (float) (region.getWidth() * scaleX),
                    (float) (region.getHeight() * scaleY));

    /* Pull the raster data from the buffered image
     * and pass it along to GDI.
     */
   ByteComponentRaster tile
            = (ByteComponentRaster)deepImage.getRaster();

    wPrinterJob.drawImage3ByteBGR(tile.getDataStorage(),
                scaledBounds.x, scaledBounds.y,
                scaledBounds.width,
                scaledBounds.height,
                0f, 0f,
                deepImage.getWidth(), deepImage.getHeight());

}