|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sap.ip.me.api.pios.printer.PrinterImage
The PrinterImage class represent an image, which can be used to render an image to the page printable area. Most printers support preloading of images to the printer's memory. The loaded image can be later referenced by name when needed for printing. Some printers may not support images altogether.
Example: Load image then print.
Connector connector = Connector.getInstance();
DriverInfo[] printers = connector.listDrivers(ConnectionType.PRINTER);
PrinterParameters parameters = new PrinterParameters(printers[0]);
parameters.setPrinterMode(PrinterParameters.GRAPHIC_MODE);
GraphicPrinter graphicPrinter = (GraphicPrinter)connector.open(parameters);
File myImage = new File("logo32x32.bmp");
if (myImage.exists()) {
BufferedInputStream bfis = null;
try {
bfis = new BufferedInputStream(new FileInputStream(myImage));
int bufferSize = (int)myImage.length();
byte[] imageBytes = new byte[bufferSize];
int i = bfis.read(imageBytes, 0, bufferSize);
if (i > 0) {
PrinterImage image = graphicPrinter.createImage("logo",
PrinterImage.IMAGE_PCX, imageBytes);
graphicPrinter.loadImage(image);
graphicPrinter.drawImage(image.getName(), 100, 100, GraphicPrinter.NO_ROTATION);
}
}
finally {
if (bfis != null) bfis.close();
}
}
graphicPrinter.doPrint(1);
graphicPrinter.close();
PrinterConnection
Field Summary | |
static int |
IMAGE_BMP
Constant to indicate a BMP image type. |
static int |
IMAGE_PCX
Constant to indicate a PCX image type. |
Constructor Summary | |
PrinterImage(java.lang.String name,
int type,
byte[] image)
Creates a new PrinterImage object using the specified name, type, and image. |
Method Summary | |
byte[] |
getBytes()
Returns the image byte array. |
abstract Metrics |
getMetrics()
Returns the image field metrics. |
java.lang.String |
getName()
Returns the image name. |
int |
getType()
Returns the image type. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int IMAGE_BMP
public static final int IMAGE_PCX
Constructor Detail |
public PrinterImage(java.lang.String name, int type, byte[] image)
name
- Name of the image on the printer.type
- Type of image, PCX or BMP.image
- Image bytes that will be sent to the printer.Method Detail |
public java.lang.String getName()
public int getType()
public byte[] getBytes()
public abstract Metrics getMetrics() throws PrinterException
PrinterException
- thrown if unable to obtain image field metrics
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |