com.openpcl.pclrenderimage.render
Class PriRasterDrawing

java.lang.Object
  extended by com.openpcl.pclrenderimage.render.PriRasterDrawing
All Implemented Interfaces:
IPluginHooksPriRasterDrawing

public class PriRasterDrawing
extends Object
implements IPluginHooksPriRasterDrawing

All the Raster drawing. The raster graphics command sequence is:
These are true printer mode level commands. Done before the start graphics and stay set through start/end raster graphics blocks:

1. Raster Presentation Direction = *r#F (where # is 0 or 3).
0 is normal portrait.
3 is landscape that flips all pixels 90 degrees clockwise.

2. Raster Resolution = *t#R (where # is 75, 100, 150, 200, 300, 600). We use only 300

3. Raster Height = *r#T (where # is the number of pixels as the height.
In Presentation Mode 3 and Landscape is flipped 90 degrees).

4. Raster Width = *r#S (where # is the number of pixels as the width.
In Presentation Mode 3 and Landscape is flipped 90 degrees).

Start
: 5. Start Raster Graphics = *r#A (where # is 0 or 1). 0 is start at left graphics margin.
1 is start at current cursor

6. Y Offset = *b#Y (Move the graphic drawing cursor down # number of pixel rows)

7. Raster Compression = *b#M (where # is 0 thru 5). See the setter method for value meanings.

8. Transfer Raster Data = *b#W (where # is the number of following data bytes).

Variations:
6. Y Offset
8. Transfer Raster Data

6. Y Offset
7. Raster Compression
8. Transfer Raster Data

7. Raster Compression
8. Transfer Raster Data

Ending:
8. Transfer Raster Data
9. End Raster Graphics = *rB and *rC (there is no # value in this command)

Author:
howard 5/17/2006

Field Summary
protected  byte[] mAfterUncompressingByteArray
           
protected  BufferedImage mBufferedImageToDrawOn
           
protected static int mDrawingBitmapWidth
           
protected  boolean mIsInRasterMode
           
protected  PclRenderImage mPclRenderImage
           
protected  int mPresentationModeDirection
           
protected  PriDecompressPclBytes mPriDecompressPclBytes
           
protected  int mRasterCompressionMethod
           
protected  byte[] mRasterDataForSoftFontChar
           
protected  int mRasterHeight
           
protected  int mRasterWidth
           
protected  int mRasterYoffset
           
protected  int mStartRasterGraphics
           
protected  byte[] mTransferRasterDataByteArray
           
protected  int mTransferRasterDataNumBytes
           
protected static int sColorBlack
           
protected static int sColorBlue
           
protected static int sColorCyan
           
protected static int sColorGreen
           
protected static int sColorRed
           
static int sPresentationModeDirectionFlipToAlongWidth
           
static int sPresentationModeDirectionSameAsOrientation
           
static int sRasterCompressionMethodAdaptive
           
static int sRasterCompressionMethodDeltaRow
           
static String[] sRasterCompressionMethodNames
           
static int sRasterCompressionMethodReserved
           
static int sRasterCompressionMethodRunLength
           
static int sRasterCompressionMethodTiff
           
static int sRasterCompressionMethodUnenconded
           
protected static int sRasterGraphicsResolution
           
static int sStartRasterGraphicsAtCurrentCursor
           
static int sStartRasterGraphicsAtLeftMargin
           
 
Constructor Summary
PriRasterDrawing(PclRenderImage pPclRenderImage)
          Constructor without passing the BufferedImage.
Needed for subclasses that don't use the BufferedImage, so don't delete or change this constructor.
PriRasterDrawing(PclRenderImage pPclRenderImage, BufferedImage pBufferedImageToDrawOn)
          Constructor
 
Method Summary
 void drawRasterPixelsOnBitmap(byte[] pUncompressedDataByteArray, int pColorAsInt, int pPosX, int pPosY)
          Draw raster pixels on the image.
Subclass plugins override this method so do not delete or rename this method.
 void drawSoftFontRasterChar(PriBitmapCharacter pCharacter)
          Draw Soft Font Char
8 bits per byte.
 void freeUpMemory()
          When the user is done with this rendering session, then free up memory.
Subclass plugins override this method so do not delete or rename this method.
 int getPresentationModeDirection()
           
 int getRasterGraphicsResolution()
           
 int getRasterHeight()
           
 int getRasterWidth()
           
 int getRasterYoffset()
           
 byte[] getTransferRasterDataBytes()
           
 int getTransferRasterDataNumBytes()
           
 void setAbsoluteRasterY(int yPos)
          Set Absolute Raster Y Offset.
Absolute set the Y pixel location for next raster draw to skip N pixel rows.
 void setEndRasterGraphics()
          Set End Raster Graphics.
It sets the internal boolean mIsInRasterMode to false.
Subclass plugins override this method so do not delete or rename this method.
 void setPresentationModeDirection(int pValue)
          Set Presentation Mode Direction.
 void setRasterCompressionMethod(int pMode)
          Set Raster Compression Method.
 void setRasterGraphicsResolution(int pValue)
          Set Raster Graphics Resolution.
 void setRasterHeight(int pValue)
          Set the height of the raster pixels.
 void setRasterWidth(int pValue)
          Set the width of the raster pixels.
 void setRasterYoffset(int pOffset)
          Set Raster Y Offset.
Relative Y pixel move for next raster draw to skip N pixel rows.
 void setStartRasterGraphics(int pValue)
          Start Raster Graphics (and also specify start at left margin or start at current cursor).
 void setToInitialValues()
          Set to initial values.
Subclass plugins override this method so do not delete or rename this method.
 void transferRasterData(int numBytes, byte[] dataByteArray)
          Set Transfer Raster Data.
Pass in the number of bytes in the raster data, and the data to convert to pixels
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mPclRenderImage

protected PclRenderImage mPclRenderImage

mBufferedImageToDrawOn

protected BufferedImage mBufferedImageToDrawOn

sPresentationModeDirectionSameAsOrientation

public static final int sPresentationModeDirectionSameAsOrientation
See Also:
Constant Field Values

sPresentationModeDirectionFlipToAlongWidth

public static final int sPresentationModeDirectionFlipToAlongWidth
See Also:
Constant Field Values

mPresentationModeDirection

protected int mPresentationModeDirection

sRasterGraphicsResolution

protected static final int sRasterGraphicsResolution
See Also:
Constant Field Values

mRasterHeight

protected int mRasterHeight

mRasterWidth

protected int mRasterWidth

sStartRasterGraphicsAtLeftMargin

public static final int sStartRasterGraphicsAtLeftMargin
See Also:
Constant Field Values

sStartRasterGraphicsAtCurrentCursor

public static final int sStartRasterGraphicsAtCurrentCursor
See Also:
Constant Field Values

mStartRasterGraphics

protected int mStartRasterGraphics

mIsInRasterMode

protected boolean mIsInRasterMode

mRasterYoffset

protected int mRasterYoffset

sRasterCompressionMethodUnenconded

public static final int sRasterCompressionMethodUnenconded
See Also:
Constant Field Values

sRasterCompressionMethodRunLength

public static final int sRasterCompressionMethodRunLength
See Also:
Constant Field Values

sRasterCompressionMethodTiff

public static final int sRasterCompressionMethodTiff
See Also:
Constant Field Values

sRasterCompressionMethodDeltaRow

public static final int sRasterCompressionMethodDeltaRow
See Also:
Constant Field Values

sRasterCompressionMethodReserved

public static final int sRasterCompressionMethodReserved
See Also:
Constant Field Values

sRasterCompressionMethodAdaptive

public static final int sRasterCompressionMethodAdaptive
See Also:
Constant Field Values

sRasterCompressionMethodNames

public static final String[] sRasterCompressionMethodNames

mRasterCompressionMethod

protected int mRasterCompressionMethod

mTransferRasterDataByteArray

protected byte[] mTransferRasterDataByteArray

mTransferRasterDataNumBytes

protected int mTransferRasterDataNumBytes

mPriDecompressPclBytes

protected PriDecompressPclBytes mPriDecompressPclBytes

mAfterUncompressingByteArray

protected byte[] mAfterUncompressingByteArray

mDrawingBitmapWidth

protected static final int mDrawingBitmapWidth
See Also:
Constant Field Values

mRasterDataForSoftFontChar

protected byte[] mRasterDataForSoftFontChar

sColorBlack

protected static final int sColorBlack

sColorRed

protected static final int sColorRed

sColorGreen

protected static final int sColorGreen

sColorBlue

protected static final int sColorBlue

sColorCyan

protected static final int sColorCyan
Constructor Detail

PriRasterDrawing

public PriRasterDrawing(PclRenderImage pPclRenderImage,
                        BufferedImage pBufferedImageToDrawOn)
Constructor


PriRasterDrawing

public PriRasterDrawing(PclRenderImage pPclRenderImage)
Constructor without passing the BufferedImage.
Needed for subclasses that don't use the BufferedImage, so don't delete or change this constructor.

Method Detail

setToInitialValues

public void setToInitialValues()
Set to initial values.
Subclass plugins override this method so do not delete or rename this method.

Specified by:
setToInitialValues in interface IPluginHooksPriRasterDrawing

freeUpMemory

public void freeUpMemory()
When the user is done with this rendering session, then free up memory.
Subclass plugins override this method so do not delete or rename this method.

Specified by:
freeUpMemory in interface IPluginHooksPriRasterDrawing

getPresentationModeDirection

public int getPresentationModeDirection()

getRasterGraphicsResolution

public int getRasterGraphicsResolution()

getRasterHeight

public int getRasterHeight()

getRasterWidth

public int getRasterWidth()

getRasterYoffset

public int getRasterYoffset()

getTransferRasterDataBytes

public byte[] getTransferRasterDataBytes()

getTransferRasterDataNumBytes

public int getTransferRasterDataNumBytes()

setPresentationModeDirection

public void setPresentationModeDirection(int pValue)
Set Presentation Mode Direction. Allowed values are 0 and 3 only.
0 = Raster image prints in orientation of logical page
3 = Raster image prints along the width of the physical page

A value of 0 indicates that a raster row ‘will be printed in the positive X-direction of the PCL coordinate system. The print direction translates the PCL coordinate system.

A value of 3 indicates that the raster graphics will be printed along the width of the physical page, regardless of logical page orientation. In portrait orientation, a raster row is printed in the positive X-direction of the PCL coordinate system and a subsequent raster row is printed beginning at the next dot row position in the positive Y-direction. In landscape orientation, a raster row is printed in the positive Y-direction of the PCL coordinate system and a subsequent raster row is printed beginning at the next dot row position in the negative X-direction. Figure 15-5 illustrates presentation mode 0 and 3. This shows that conceptually, the graphic to be printed, prints rotated 90 degrees.

For example a graphic arrow pointing to the right using mode 0 will print as pointing down using mode 3, rotated on the upper left hand corner with all the points being mapped clockwise 90 degrees.

Parameters:
pValue -

setRasterGraphicsResolution

public void setRasterGraphicsResolution(int pValue)
Set Raster Graphics Resolution. Dots per inch for raster graphics drawing.
All our PCL files we view must be 300 DPI only, and not any other DPI.

Parameters:
pValue -

setRasterHeight

public void setRasterHeight(int pValue)
Set the height of the raster pixels. Note that in Presentation Mode 3 and Landscape, all pixels are flipped 90 degrees clockwise, and the height orientation too.

Parameters:
pValue -

setRasterWidth

public void setRasterWidth(int pValue)
Set the width of the raster pixels. Note that in Presentation Mode 3 and Landscape, all pixels are flipped 90 degrees clockwise, and the width orientation too.

Parameters:
pValue -

setStartRasterGraphics

public void setStartRasterGraphics(int pValue)
Start Raster Graphics (and also specify start at left margin or start at current cursor). Values 0 and 1 only. A value of 0 specifies that the left graphics margin is at the default left margin of the page (X-position 0). A value of 1 specifies that the left graphics margin is at the current X-position. In presentation mode 3, the location of the left graphics margin varies depending on the orientation.

Once a Start Raster Graphics command is received by the printer, raster graphics resolution, raster graphics presentation mode, raster height, raster width, and left raster graphics margin are fixed until an end raster graphics command is received.

Subclass plugins override this method so do not delete or rename this method.

Specified by:
setStartRasterGraphics in interface IPluginHooksPriRasterDrawing
Parameters:
pValue -

setRasterYoffset

public void setRasterYoffset(int pOffset)
Set Raster Y Offset.
Relative Y pixel move for next raster draw to skip N pixel rows.

Parameters:
pOffset -

setAbsoluteRasterY

public void setAbsoluteRasterY(int yPos)
Set Absolute Raster Y Offset.
Absolute set the Y pixel location for next raster draw to skip N pixel rows.

Parameters:
yPos -

setRasterCompressionMethod

public void setRasterCompressionMethod(int pMode)
Set Raster Compression Method. Values 0 thru 5 only.
0 - Unencoded
1 - Run-length encoding
2 - Tagged Imaged File Format (TIFF) rev. 4.0
3 - Delta row compression
4 - Reserved
5 - Adaptive compression

Parameters:
pMode -

transferRasterData

public void transferRasterData(int numBytes,
                               byte[] dataByteArray)
Set Transfer Raster Data.
Pass in the number of bytes in the raster data, and the data to convert to pixels

Parameters:
numBytes -
byteArray -

drawRasterPixelsOnBitmap

public void drawRasterPixelsOnBitmap(byte[] pUncompressedDataByteArray,
                                     int pColorAsInt,
                                     int pPosX,
                                     int pPosY)
Draw raster pixels on the image.
Subclass plugins override this method so do not delete or rename this method.

Specified by:
drawRasterPixelsOnBitmap in interface IPluginHooksPriRasterDrawing
Parameters:
pUncompressedDataByteArray -
pColorAsInt -
pPosX -
pPosY -

setEndRasterGraphics

public void setEndRasterGraphics()
Set End Raster Graphics.
It sets the internal boolean mIsInRasterMode to false.
Subclass plugins override this method so do not delete or rename this method.

Specified by:
setEndRasterGraphics in interface IPluginHooksPriRasterDrawing

drawSoftFontRasterChar

public void drawSoftFontRasterChar(PriBitmapCharacter pCharacter)
Draw Soft Font Char
8 bits per byte. Each bit in the 8 bit byte will be drawn as a dot on the image.
There will be wasted bits on the right of the right most byte when the int width is not a multiple of 8.
For example, if 19 bytes wide, then it's 2 bytes making 16, then 1 more byte to hold the last 3 bits, so 5 wasted bits for each row of bits. If the height of the char is 40, then there will be the last 5 bits of the rightmost byte X 40 rows of bits = 200 wasted bits, and the number of bytes needed is 3 bytes wide to hold the 19 bits X 40 rows = 120 bytes.

Parameters:
pCharacter -


OpenPCL http://www.openpcl.com