xmlgraphics-commons 1.2

org.apache.xmlgraphics.ps
Class PSImageUtils

java.lang.Object
  extended by org.apache.xmlgraphics.ps.PSImageUtils

public class PSImageUtils
extends java.lang.Object

Utility code for rendering images in PostScript.


Constructor Summary
PSImageUtils()
           
 
Method Summary
static int[] getRGB(java.awt.image.RenderedImage img, int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)
          Extracts a packed RGB integer array of a RenderedImage.
static void paintForm(PSResource form, java.awt.geom.Rectangle2D targetRect, PSGenerator gen)
          Paints a reusable image (previously added as a PostScript form).
static void paintReusableImage(java.lang.String formName, java.awt.geom.Rectangle2D targetRect, PSGenerator gen)
          Paints a reusable image (previously added as a PostScript form).
static void renderBitmapImage(java.awt.image.RenderedImage img, float x, float y, float w, float h, PSGenerator gen)
          Renders a bitmap image to PostScript.
static void renderEPS(byte[] rawEPS, java.lang.String name, float x, float y, float w, float h, float bboxx, float bboxy, float bboxw, float bboxh, PSGenerator gen)
          Places an EPS file in the PostScript stream.
static void writeImage(byte[] img, java.awt.Dimension imgDim, java.lang.String imgDescription, java.awt.geom.Rectangle2D targetRect, boolean isJPEG, java.awt.color.ColorSpace colorSpace, PSGenerator gen)
          Writes a bitmap image to the PostScript stream.
static PSResource writeReusableImage(byte[] img, java.awt.Dimension imgDim, java.lang.String formName, java.lang.String imageDescription, boolean isJPEG, java.awt.color.ColorSpace colorSpace, PSGenerator gen)
          Writes a bitmap image as a PostScript form enclosed by DSC resource wrappers to the PostScript file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PSImageUtils

public PSImageUtils()
Method Detail

writeImage

public static void writeImage(byte[] img,
                              java.awt.Dimension imgDim,
                              java.lang.String imgDescription,
                              java.awt.geom.Rectangle2D targetRect,
                              boolean isJPEG,
                              java.awt.color.ColorSpace colorSpace,
                              PSGenerator gen)
                       throws java.io.IOException
Writes a bitmap image to the PostScript stream.

Parameters:
img - the bitmap image as a byte array
imgDim - the dimensions of the image
imgDescription - the name of the image
targetRect - the target rectangle to place the image in
isJPEG - true if "img" contains a DCT-encoded images, false if "img" contains the decoded bitmap
colorSpace - the color space of the image
gen - the PostScript generator
Throws:
java.io.IOException - In case of an I/O exception

writeReusableImage

public static PSResource writeReusableImage(byte[] img,
                                            java.awt.Dimension imgDim,
                                            java.lang.String formName,
                                            java.lang.String imageDescription,
                                            boolean isJPEG,
                                            java.awt.color.ColorSpace colorSpace,
                                            PSGenerator gen)
                                     throws java.io.IOException
Writes a bitmap image as a PostScript form enclosed by DSC resource wrappers to the PostScript file.

Parameters:
img - the raw bitmap data
imgDim - the dimensions of the image
formName - the name of the PostScript form to use
imageDescription - a description of the image added as a DSC Title comment
isJPEG - true if "img" contains a DCT-encoded images, false if "img" contains the decoded bitmap
colorSpace - the color space of the image
gen - the PostScript generator
Returns:
a PSResource representing the form for resource tracking
Throws:
java.io.IOException - In case of an I/O exception

paintReusableImage

public static void paintReusableImage(java.lang.String formName,
                                      java.awt.geom.Rectangle2D targetRect,
                                      PSGenerator gen)
                               throws java.io.IOException
Paints a reusable image (previously added as a PostScript form).

Parameters:
formName - the name of the PostScript form implementing the image
targetRect - the target rectangle to place the image in
gen - the PostScript generator
Throws:
java.io.IOException - In case of an I/O exception

paintForm

public static void paintForm(PSResource form,
                             java.awt.geom.Rectangle2D targetRect,
                             PSGenerator gen)
                      throws java.io.IOException
Paints a reusable image (previously added as a PostScript form).

Parameters:
form - the PostScript form resource implementing the image
targetRect - the target rectangle to place the image in
gen - the PostScript generator
Throws:
java.io.IOException - In case of an I/O exception

renderBitmapImage

public static void renderBitmapImage(java.awt.image.RenderedImage img,
                                     float x,
                                     float y,
                                     float w,
                                     float h,
                                     PSGenerator gen)
                              throws java.io.IOException
Renders a bitmap image to PostScript.

Parameters:
img - image to render
x - x position
y - y position
w - width
h - height
gen - PS generator
Throws:
java.io.IOException - In case of an I/O problem while rendering the image

getRGB

public static int[] getRGB(java.awt.image.RenderedImage img,
                           int startX,
                           int startY,
                           int w,
                           int h,
                           int[] rgbArray,
                           int offset,
                           int scansize)
Extracts a packed RGB integer array of a RenderedImage.

Parameters:
img - the image
startX - the starting X coordinate
startY - the starting Y coordinate
w - the width of the cropped image
h - the height of the cropped image
rgbArray - the prepared integer array to write to
offset - offset in the target array
scansize - width of a row in the target array
Returns:
the populated integer array previously passed in as rgbArray parameter

renderEPS

public static void renderEPS(byte[] rawEPS,
                             java.lang.String name,
                             float x,
                             float y,
                             float w,
                             float h,
                             float bboxx,
                             float bboxy,
                             float bboxw,
                             float bboxh,
                             PSGenerator gen)
                      throws java.io.IOException
Places an EPS file in the PostScript stream.

Parameters:
rawEPS - byte array containing the raw EPS data
name - name for the EPS document
x - x-coordinate of viewport in millipoints
y - y-coordinate of viewport in millipoints
w - width of viewport in millipoints
h - height of viewport in millipoints
bboxx - x-coordinate of EPS bounding box in points
bboxy - y-coordinate of EPS bounding box in points
bboxw - width of EPS bounding box in points
bboxh - height of EPS bounding box in points
gen - the PS generator
Throws:
java.io.IOException - in case an I/O error happens during output

xmlgraphics-commons 1.2

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.