|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.hcilab.btprinter.abstractionlayer.ImageHandler
public abstract class ImageHandler
This class provides an abstraction layer for the image processing as image handling (e.g. raw pixel access) may be different on different platforms. It defines methods to provide a per line access to the image data in a format that is understood by the printer. These methods have to be implemented for each supported platform separatly.
The intention of the per line access is to save memory by not keeping the whole processed image. The driver can request line by line and can send them directly to the printer.
This class also holds two shared methods that can be invoked from the platform specific implementation to process and compress the image.
ToDo
| Field Summary | |
|---|---|
static int |
MAX_IMG_HEIGHT
Maximum image height supported by the printer. |
static int |
MAX_IMG_WIDTH
Maximum image width supported by the printer. |
| Constructor Summary | |
|---|---|
ImageHandler()
|
|
| Method Summary | |
|---|---|
byte[] |
compressImageLine(byte[] imgLine)
Compresses a line of an image. |
abstract int |
getLineCount()
Provides the number of lines of the current image (meaning the image height) for user interface purposes. |
abstract byte[] |
getNextLine()
Returns the next line of the image in a compressed format (see also compressImageLine) and moves the internal line pointer forward by one line. |
abstract boolean |
hasNextLine()
Checks if there are more lines to be processed in the current image. |
abstract void |
initialize(java.lang.Object imgObject)
Initializes the current image handler meaning that the image is taken and compressed by request (getNextLine). |
byte[] |
processImageLine(byte[] pixels)
Converts a line of an image. |
abstract void |
setLogHandler(LogHandler logHandler)
Sets the log handler. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_IMG_HEIGHT
public static final int MAX_IMG_WIDTH
| Constructor Detail |
|---|
public ImageHandler()
| Method Detail |
|---|
public byte[] compressImageLine(byte[] imgLine)
If the output of the processImageLine method is taken as input for this method, the output array of this method is understood by the printer as an image line and therefore can directly be sent to it (after adding sequence control codes).
imgLine - Processed line of image
public abstract int getLineCount()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - If image handler has not been initialized yet
public abstract byte[] getNextLine()
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException,
java.util.NoSuchElementException
java.lang.IllegalStateException - If image handler has not been initialized yet
java.lang.IllegalArgumentException - If the image dimension is not supported (see processImage)
java.util.NoSuchElementException - If there are no more lines
public abstract boolean hasNextLine()
throws java.lang.IllegalStateException
java.lang.IllegalStateException - If image handler has not been initialized yet
public abstract void initialize(java.lang.Object imgObject)
throws java.lang.IllegalArgumentException
imgObject - Object that represents an image (platform specific)
java.lang.IllegalArgumentException - If type of image is not recognized or if dimension is not
supported
public byte[] processImageLine(byte[] pixels)
throws java.lang.IllegalArgumentException
The output consists of an byte array where each byte holds eight pixels which can be either black or white. The decision wether an input pixel is considered being black or white is made by the threshold value (here: 128). The direction of the line is reversed as required by the printer.
The output has to be forwarded to the compressImageLine method as the printer will not understand the byte array returned by this method.
Right now there are only images supported where the pixel number per line is a multiple of 8. If the number of pixels is smaller than the printable area, white pixels will be added to the left. The image height cannot be checked here as the processing is done by line.
pixels - Line of source image
java.lang.IllegalArgumentException - If the image dimension is not supportedpublic abstract void setLogHandler(LogHandler logHandler)
logHandler - Log handler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||