Class converter

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by converter
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class converter
extends java.awt.Canvas

This class initialize all the variables including the the integers, pixels and so fourth. The state is enable. There are no OS/Hardware dependencies and no variances. There is no need for any security constraints and no references to external specifications.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  int bfOffBits
          Initialization of bit map off bits by addition of BITMAPFILEHEADER and BITMAPINFOHEADER.
private  int bfReserved1
          Initialization of bitmap file reserved1 with the value 0.
private  int bfReserved2
          Initialization of bitmap file reserved2 with the value 0.
private  int bfSize
          Initialization of bitmap file size with the value 0.
private  byte[] bfType
          Initialization of bfType as an array of type byte with the value B and M casted by byte.
private  int biBitCount
          Initialization of bitmap info bit count with the size of 24.
private  int biClrImportant
          Initialization of bitmap info important color indicator with the size of 0.
private  int biClrUsed
          Initialization of bitmap info color used indicator with the size of 0.
private  int biCompression
          Initialization of bitmap info compression with the size of 0.
private  int biHeight
          Initialization of bitmap info height with the size of 0.
private  int biPlanes
          Initialization of bitmap info planes with the size of 1.
private  int biSize
          Initialization of bitmap info size by BITMAPINFOHEADER_SIZE.
private  int biSizeImage
          Initialization of bitmap info image size with the size of 0x030000.
private  int[] bitmap
          Bipmap integer array that creates an bitmap raw data.
private  byte[] bitmapFileHeader
          Initialization of bitmap file header as an array of type byte with the size of 14.
private static int BITMAPFILEHEADER_SIZE
          A size of bitmap file header to 14 as a final integer.
private  byte[] bitmapInfoHeader
          Initialization of bitmap info header as an array of type byte with the size of 40.
private static int BITMAPINFOHEADER_SIZE
          A size of bipmap info header to 40 as a final integer.
private  int biWidth
          Initialization of bitmap info width with the size of 0.
private  int biXPelsPerMeter
          Initialization of bitmap info x-pixel per meter with the size of 0x0.
private  int biYPelsPerMeter
          Initialization of bitmap info y-pixel per meter with the size of 0x0.
(package private)  short BMPbitsPerPixel
          Number of bits per pixel - 1, 4, 8, or 24 (no color map).
(package private)  int BMPcolorsImportant
          Number of important colors (appear first in palette) (0 means all are important).
(package private)  int BMPcolorsUsed
          Number of colors in palette (if 0, calculate).
(package private)  int BMPcompression
          Compression methods used: 0 (none), 1 (8-bit RLE), or 2 (4-bit RLE).
(package private)  int BMPheadersize
          Integer value of bitmap header size.
(package private)  int BMPheight
          Integer value of bitmap height size in pixels.
(package private)  int BMPhorzResolution
          Horizontal resolution, pixels/meter (may be 0).
(package private)  java.awt.Image BMPimage
          Bitmap image representation.
(package private)  int BMPimageoffset
          Integer value of bitmap image offset.
(package private)  short BMPplanes
          Short value of color planes, always 1.
(package private)  int BMPreserved
          Integer value of the preserved description of bitmap.
(package private)  int BMPsize
          Integer value of the size of bitmap that describes the header in bytes.
(package private)  int BMPsizeOfBitmap
          Size of bitmap in bytes (may be 0: if so, calculate).
(package private)  int BMPvertResolution
          Vertical resolution, pixels/meter (may be 0).
(package private)  int BMPwidth
          Integer value of bitmap width size in pixels.
private  byte[] bytebuffer
          bytebuffer object that creates byte type array.
(package private)  int bytesPerLine
          Indicator of bytes per line.
(package private)  int colorIndex
          Color index.
(package private)  java.awt.Color[] colorTable
          Color table array.
private  java.io.DataInputStream d
          DataInputStream object to be used with byte-based file stream.
private  java.io.FileOutputStream fo
          FileOutputStream object that performs byte-based output stream.
private  int i
          Integer value to be used as an index.
private  int j
          Integer value to be used as an index.
(package private)  int[] pixels
          Array of pixels.
(package private)  byte[] scanline
          Byte type array of scan line.
private  int type
          Bitmap type with integer value.
private  short windowInt
          windowInt short value to be used when converting occurs between long and integer.
private  int windowLong
          windowLong integer value to be used when converting occurs between long and integer.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
converter()
           
 
Method Summary
 void BufferedImageToFile(java.io.FileOutputStream in_fo, java.awt.image.BufferedImage parImage, int type)
          This method sets up the image in the buffer.
 boolean convertImage(java.awt.Image parImage, int parWidth, int parHeight)
          convertImage converts the memory image to the bitmap format (BRG).
 java.awt.image.BufferedImage FileToBufferedImage(java.io.FileInputStream is)
          This method sets up the image in the buffer.
 short flipInt(byte[] byteFlip)
          Reads byte array object and converts it to short value.
 int flipLong(byte[] byteFlip)
          Reads byte array object and converts it to int value.
 byte[] intToDWord(int parValue)
          intToDWord converts an int to a double word, where the return value is stored in a 4-byte array.
 byte[] intToWord(int parValue)
          intToWord converts an int to a word, where the return value is stored in a 2-byte array.
static void main(java.lang.String[] args)
          This method is the main function that calls all the other ones There is no state transition.
 void parseit()
          This method calls the parseit function and initialize it to 0 There is no state transition.
 void parseit(int typeFlag)
          This method prints out the results of the image There is no state transition.
 short readInt(java.io.DataInputStream d)
          Reads DataInputStream and converts it to long value.
 int readLong(java.io.DataInputStream d)
          Reads DataInputStream and converts it to int value.
 void save(java.awt.Image parImage, int parWidth, int parHeight)
          The saveMethod is the main method of the process.
 java.awt.Color win2Color(int colorValue)
          Sets windows RGB color value.
 void writeBitmap()
          writeBitmap converts the image returned from the pixel grabber to the format required.
 void writeBitmapFileHeader()
          writeBitmapFileHeader writes the bitmap file header to the file.
 void writeBitmapInfoHeader()
          writeBitmapInfoHeader writes the bitmap information header to the file.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BITMAPFILEHEADER_SIZE

private static final int BITMAPFILEHEADER_SIZE
A size of bitmap file header to 14 as a final integer.

See Also:
Constant Field Values

BITMAPINFOHEADER_SIZE

private static final int BITMAPINFOHEADER_SIZE
A size of bipmap info header to 40 as a final integer.

See Also:
Constant Field Values

bitmapFileHeader

private byte[] bitmapFileHeader
Initialization of bitmap file header as an array of type byte with the size of 14.


bfType

private byte[] bfType
Initialization of bfType as an array of type byte with the value B and M casted by byte.


bfSize

private int bfSize
Initialization of bitmap file size with the value 0.


bfReserved1

private int bfReserved1
Initialization of bitmap file reserved1 with the value 0.


bfReserved2

private int bfReserved2
Initialization of bitmap file reserved2 with the value 0.


bfOffBits

private int bfOffBits
Initialization of bit map off bits by addition of BITMAPFILEHEADER and BITMAPINFOHEADER.


bitmapInfoHeader

private byte[] bitmapInfoHeader
Initialization of bitmap info header as an array of type byte with the size of 40.


biSize

private int biSize
Initialization of bitmap info size by BITMAPINFOHEADER_SIZE.


biWidth

private int biWidth
Initialization of bitmap info width with the size of 0.


biHeight

private int biHeight
Initialization of bitmap info height with the size of 0.


biPlanes

private int biPlanes
Initialization of bitmap info planes with the size of 1.


biBitCount

private int biBitCount
Initialization of bitmap info bit count with the size of 24.


biCompression

private int biCompression
Initialization of bitmap info compression with the size of 0.


biSizeImage

private int biSizeImage
Initialization of bitmap info image size with the size of 0x030000.


biXPelsPerMeter

private int biXPelsPerMeter
Initialization of bitmap info x-pixel per meter with the size of 0x0.


biYPelsPerMeter

private int biYPelsPerMeter
Initialization of bitmap info y-pixel per meter with the size of 0x0.


biClrUsed

private int biClrUsed
Initialization of bitmap info color used indicator with the size of 0.


biClrImportant

private int biClrImportant
Initialization of bitmap info important color indicator with the size of 0.


type

private int type
Bitmap type with integer value.


bitmap

private int[] bitmap
Bipmap integer array that creates an bitmap raw data.


fo

private java.io.FileOutputStream fo
FileOutputStream object that performs byte-based output stream.


bytebuffer

private byte[] bytebuffer
bytebuffer object that creates byte type array.


i

private int i
Integer value to be used as an index.


j

private int j
Integer value to be used as an index.


windowLong

private int windowLong
windowLong integer value to be used when converting occurs between long and integer.


windowInt

private short windowInt
windowInt short value to be used when converting occurs between long and integer.


d

private java.io.DataInputStream d
DataInputStream object to be used with byte-based file stream.


BMPsize

int BMPsize
Integer value of the size of bitmap that describes the header in bytes.


BMPreserved

int BMPreserved
Integer value of the preserved description of bitmap.


BMPimageoffset

int BMPimageoffset
Integer value of bitmap image offset.


BMPheadersize

int BMPheadersize
Integer value of bitmap header size.


BMPwidth

int BMPwidth
Integer value of bitmap width size in pixels.


BMPheight

int BMPheight
Integer value of bitmap height size in pixels.


BMPplanes

short BMPplanes
Short value of color planes, always 1.


BMPbitsPerPixel

short BMPbitsPerPixel
Number of bits per pixel - 1, 4, 8, or 24 (no color map).


BMPcompression

int BMPcompression
Compression methods used: 0 (none), 1 (8-bit RLE), or 2 (4-bit RLE).


BMPsizeOfBitmap

int BMPsizeOfBitmap
Size of bitmap in bytes (may be 0: if so, calculate).


BMPhorzResolution

int BMPhorzResolution
Horizontal resolution, pixels/meter (may be 0).


BMPvertResolution

int BMPvertResolution
Vertical resolution, pixels/meter (may be 0).


BMPcolorsUsed

int BMPcolorsUsed
Number of colors in palette (if 0, calculate).


BMPcolorsImportant

int BMPcolorsImportant
Number of important colors (appear first in palette) (0 means all are important).


colorTable

java.awt.Color[] colorTable
Color table array.


pixels

int[] pixels
Array of pixels.


colorIndex

int colorIndex
Color index.


bytesPerLine

int bytesPerLine
Indicator of bytes per line.


scanline

byte[] scanline
Byte type array of scan line.


BMPimage

java.awt.Image BMPimage
Bitmap image representation.

Constructor Detail

converter

public converter()
Method Detail

FileToBufferedImage

public java.awt.image.BufferedImage FileToBufferedImage(java.io.FileInputStream is)
This method sets up the image in the buffer. It stores the image or drawing in the memory. There is no state transition. The argument value is FileInputStream. There are no NULL value. The return value is a BufferedImage. The method stores the drawing in the buffer. There are no OS/Hardware dependencies and no variances. Implementation Variances are not allowed. There is one exception. There is no security constraints.

Parameters:
is - This is a FileInputStream variable used to get data input stream
Returns:
The return type is a BufferedImage variable

BufferedImageToFile

public void BufferedImageToFile(java.io.FileOutputStream in_fo,
                                java.awt.image.BufferedImage parImage,
                                int type)
This method sets up the image in the buffer. It stores the image or drawing in the memory. There is no state transition. The argument value is FileInputStream, BufferedImage and a int. There are no NULL value. There are no return values. The method stores the drawing in the buffer. There are no OS/Hardware dependencies and no variances. Implementation Variances are not allowed. There is one exception. There is no security constraints.

Parameters:
in_fo - is a FileInputStream variable
parImage - is a BufferedImage variable
type - is a int variable

parseit

public void parseit()
             throws java.io.IOException
This method calls the parseit function and initialize it to 0 There is no state transition. There are no argument. There are no NULL values. There are no return values. The method calls the parseit function. There are no OS/Hardware dependencies and no variances. Implementation Variances are not allowed. There is one exception. There is no security constraints.

Throws:
java.io.IOException - there is an exception

parseit

public void parseit(int typeFlag)
             throws java.io.IOException
This method prints out the results of the image There is no state transition. The argument is an int. There are no NULL values. There are no return values. The method calls all the print function. There are no OS/Hardware dependencies and no variances. Implementation Variances are not allowed. There is one exception. There is no security constraints.

Parameters:
typeFlag - this is an int variable
Throws:
java.io.IOException - there is an exception

win2Color

public java.awt.Color win2Color(int colorValue)
Sets windows RGB color value. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
colorValue - used to set windows RGB color value.
Returns:
new Color RGB value.

readLong

public int readLong(java.io.DataInputStream d)
Reads DataInputStream and converts it to int value. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
d - DataInputStream.
Returns:
fliplong/99 returns integer value if no error occurs, otherwise it returns 99.

readInt

public short readInt(java.io.DataInputStream d)
Reads DataInputStream and converts it to long value. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
d - DataInputStream.
Returns:
flipint/99 returns short value when no error occurs, otherwise it returns 99.

flipLong

public int flipLong(byte[] byteFlip)
Reads byte array object and converts it to int value. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
byteFlip - byte type array.
Returns:
readInt/0 returns integer value when no error occurs, otherwise it returns o.

flipInt

public short flipInt(byte[] byteFlip)
Reads byte array object and converts it to short value. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
byteFlip - byte type array.
Returns:
readInt/0 returns short value when no error occurs, otherwise it returns o.

save

public void save(java.awt.Image parImage,
                 int parWidth,
                 int parHeight)
The saveMethod is the main method of the process. This method will call the convertImage method to convert the memory image to a byte array; method writeBitmapFileHeader creates and writes the bitmap file header; writeBitmapInfoHeader creates the information header; and writeBitmap writes the image. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
parImage - Image object.
parWidth - int value that determines the size of width.
parHeight - int value that determines the size of height.

convertImage

public boolean convertImage(java.awt.Image parImage,
                            int parWidth,
                            int parHeight)
convertImage converts the memory image to the bitmap format (BRG). It also computes some information for the bitmap info header. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
parImage - Image object.
parWidth - int value that determines the size of width.
parHeight - int value that determines the size of height.
Returns:
true/false returns true when image is successfully converted, otherwise false.

writeBitmap

public void writeBitmap()
writeBitmap converts the image returned from the pixel grabber to the format required. Remember: scan lines are inverted in a bitmap file. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications. Each scan line must be padded to an even 4-byte boundary.


writeBitmapFileHeader

public void writeBitmapFileHeader()
writeBitmapFileHeader writes the bitmap file header to the file. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.


writeBitmapInfoHeader

public void writeBitmapInfoHeader()
writeBitmapInfoHeader writes the bitmap information header to the file. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.


intToWord

public byte[] intToWord(int parValue)
intToWord converts an int to a word, where the return value is stored in a 2-byte array. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
parValue - resets the value of the elements in the byte array.
Returns:
retValue returns a newly updated byte array.

intToDWord

public byte[] intToDWord(int parValue)
intToDWord converts an int to a double word, where the return value is stored in a 4-byte array. There are no OS/Hardware dependencies and no variances. There are no security constraints. There are no references to external specifications.

Parameters:
parValue - resets the value of elements in the byte array.
Returns:
retValue returns a newly updated byte array.

main

public static void main(java.lang.String[] args)
This method is the main function that calls all the other ones There is no state transition. The argument is a string variable. NULL value can be assigned. main function does everything. There are no OS/Hardware dependencies and no variances. Implementation variances is not allowed. There is no exception. There is no security constraints.

Parameters:
args - This is a string variable