com.jniwrapper.win32.gdi
Class Bitmap

java.lang.Object
  extended bycom.jniwrapper.Parameter
      extended bycom.jniwrapper.Pointer.Void
          extended bycom.jniwrapper.win32.Handle
              extended bycom.jniwrapper.win32.gdi.GdiObject
                  extended bycom.jniwrapper.win32.gdi.Bitmap
All Implemented Interfaces:
com.jniwrapper.IntegerParameter, com.jniwrapper.PointerParameter
Direct Known Subclasses:
DDBitmap, DIBitmap

public abstract class Bitmap
extends GdiObject

This class represents common functionality for working with bitmaps.


Nested Class Summary
static class Bitmap.Compression
          Class Compression represents compression level enumeration.
static class Bitmap.PredefinedBitmap
          Class PredefinedBitmap enumeration represents predefined windows bitmaps.
 
Nested classes inherited from class com.jniwrapper.win32.gdi.GdiObject
GdiObject.ImageLoadParameters, GdiObject.ImageType, GdiObject.Type
 
Field Summary
protected static BitmapBuilderFactory _builderFactory
           
protected static int BLACK_COLOR
           
protected static int CBM_INIT
          Initialize bitmap.
protected static int DIB_PAL_COLORS
          Color table in palette indixes.
protected static int DIB_RGB_COLORS
          Color table in RGB.
protected static java.lang.String FUNCTION_CREATEDIBITMAP
           
protected static java.lang.String FUNCTION_GET_DIBITS
           
protected static java.lang.String FUNCTION_SET_DIBITS
           
protected static int WHITE_COLOR
           
 
Fields inherited from class com.jniwrapper.win32.gdi.GdiObject
GDI_ERROR, HGDI_ERROR
 
Fields inherited from class com.jniwrapper.win32.Handle
INFINITE_TIMEOUT, INVALID_HANDLE_VALUE, STATUS_ABANDONED_WAIT_0, STATUS_TIMEOUT, STATUS_WAIT_0
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
Bitmap()
           
Bitmap(long value)
           
 
Method Summary
 void createDIBSection(DIBitmap result, DC hdc, BitmapInfo bitmapInfo, int colorModel, com.jniwrapper.Pointer ppvBits, Handle hSection, int dwOffset)
          Creates a handle to device independent bitmap (DIB).
 void createDIBSection(DIBitmap result, com.jniwrapper.Pointer ppvBits, BitmapInfo bitmapInfo)
          Creates a handle to device independent bitmap (DIB).
 void deleteObject()
          Deletes the object.
 int getBitCount()
          Returns the number of bits per pixel.
abstract  BitmapInfo getBitmapInfo()
           
abstract  BitmapInfoHeader getBitmapInfoHeader()
           
 int getBitmapLineLength()
          Return number of pixels in line.
abstract  byte[] getBytes()
          Returns array of device independent bitmap bytes as byte array.
protected static int getBytesCount(int height, int width, int bitPerPixel)
          Return number of bytes in bitmap
 long getDIBits(DC dc, int startScan, int scanLines, com.jniwrapper.Pointer.Void bits, BitmapInfo bitmapInfo, int colorModelType)
          Returns bits of a bitmap.
 long getDIBits(DC dc, int startScan, int scanLines, com.jniwrapper.Pointer bits, BitmapInfo bitmapInfo, int colorModelType)
          Returns bits of a bitmap.
abstract  com.jniwrapper.PrimitiveArray getDIBytes()
          Deprecated. use {#getBytes} method to obtain byte array of image
 int getHeight()
          Returns bitmap height in pixels.
 Size getSize()
          Return bitmap size as an Size object instance.
 Bitmap getTransparentMask()
          Returns transparancy bitmap mask.
 int getWidth()
          Returns bitmap width.
 boolean isTransparent()
          Returns true if a transparent bitmap.
abstract  void loadFromFile(java.lang.String fileName)
           
 void saveToFile(java.lang.String fileName)
          Saves bitmap to the specified file.
 long setDIBits(DC dc, int startScan, int scanLines, com.jniwrapper.Pointer bits, BitmapInfo bitmapInfo, int colorModelType)
          Sets bits for a bitmap.
abstract  void setDIBytes(com.jniwrapper.PrimitiveArray bytes)
          Sets bytes of the bitmap.
protected  void setSize(int width, int height)
          Sets bitmap size in pixels.
protected  void setTransparentMask(java.awt.Image transparentMask)
          Sets transparency mask using input image.
 java.awt.image.BufferedImage toImage()
          Converts windows Bitmap to BufferedImage.
 
Methods inherited from class com.jniwrapper.win32.gdi.GdiObject
getObject, getObjectType
 
Methods inherited from class com.jniwrapper.win32.Handle
clone, closeHandle, equals, waitFor, waitFor
 
Methods inherited from class com.jniwrapper.Pointer.Void
asFunction, asFunction, asTypedPointer, castTo, getDebugInfo, getLength, getValue, hashCode, isNull, read, setValue, toString, write
 
Methods inherited from class com.jniwrapper.Parameter
, a, a, acceptIOPerformer, asReturnValue, b, dataBufferAssigned, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, indent, pop, push, read, read, setDataBuffer, toByteArray, write
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_builderFactory

protected static final BitmapBuilderFactory _builderFactory

FUNCTION_GET_DIBITS

protected static final java.lang.String FUNCTION_GET_DIBITS
See Also:
Constant Field Values

FUNCTION_SET_DIBITS

protected static final java.lang.String FUNCTION_SET_DIBITS
See Also:
Constant Field Values

FUNCTION_CREATEDIBITMAP

protected static final java.lang.String FUNCTION_CREATEDIBITMAP
See Also:
Constant Field Values

BLACK_COLOR

protected static final int BLACK_COLOR
See Also:
Constant Field Values

WHITE_COLOR

protected static final int WHITE_COLOR
See Also:
Constant Field Values

DIB_RGB_COLORS

protected static final int DIB_RGB_COLORS
Color table in RGB.

See Also:
Constant Field Values

DIB_PAL_COLORS

protected static final int DIB_PAL_COLORS
Color table in palette indixes.

See Also:
Constant Field Values

CBM_INIT

protected static final int CBM_INIT
Initialize bitmap.

See Also:
Constant Field Values
Constructor Detail

Bitmap

public Bitmap()

Bitmap

public Bitmap(long value)
Method Detail

setDIBits

public long setDIBits(DC dc,
                      int startScan,
                      int scanLines,
                      com.jniwrapper.Pointer bits,
                      BitmapInfo bitmapInfo,
                      int colorModelType)
Sets bits for a bitmap.

Parameters:
dc - dc compatible with a bitmap.
startScan - start scanline in a bitmap.
scanLines - the number of scanlines in a bitmap.
bits - a pointer to PrimitiveArray of UInt8 (result bits).
bitmapInfo - BitmapInfo structure describing a bitmap.
colorModelType - a type of color model.
Returns:
the number of scanlines with bits.

getDIBits

public long getDIBits(DC dc,
                      int startScan,
                      int scanLines,
                      com.jniwrapper.Pointer bits,
                      BitmapInfo bitmapInfo,
                      int colorModelType)
Returns bits of a bitmap.

Parameters:
dc - dc compatible with a bitmap.
startScan - start scanline in bitmap.
scanLines - the number of scanlines in a bitmap.
bits - a pointer to PrimitiveArray of UInt8 (result bits).
bitmapInfo - BitmapInfo structure describing a bitmap.
colorModelType - a type of color model.
Returns:
the number of scanlines with bits.

getDIBits

public long getDIBits(DC dc,
                      int startScan,
                      int scanLines,
                      com.jniwrapper.Pointer.Void bits,
                      BitmapInfo bitmapInfo,
                      int colorModelType)
Returns bits of a bitmap.

Parameters:
dc - dc compatible with a bitmap.
startScan - start scanline in bitmap.
scanLines - the number of scanlines in a bitmap.
bits - a pointer to PrimitiveArray of UInt8 (result bits).
bitmapInfo - BitmapInfo structure describing a bitmap.
colorModelType - a type of color model.
Returns:
the number of scanlines with bits.

setSize

protected void setSize(int width,
                       int height)
Sets bitmap size in pixels.

Parameters:
width -
height -

getSize

public Size getSize()
Return bitmap size as an Size object instance.

Returns:
Size object instance

getWidth

public int getWidth()
Returns bitmap width.

Returns:
width - bitmap width in pixels

getHeight

public int getHeight()
Returns bitmap height in pixels.

Returns:
height - bitmap height in pixels

createDIBSection

public void createDIBSection(DIBitmap result,
                             com.jniwrapper.Pointer ppvBits,
                             BitmapInfo bitmapInfo)
Creates a handle to device independent bitmap (DIB).

Parameters:
result - [out] is a handle to DIB.
ppvBits - [out] is a pointer to the location of bits in DIB section.
bitmapInfo - [in] describes source DDBitmap.

createDIBSection

public void createDIBSection(DIBitmap result,
                             DC hdc,
                             BitmapInfo bitmapInfo,
                             int colorModel,
                             com.jniwrapper.Pointer ppvBits,
                             Handle hSection,
                             int dwOffset)
Creates a handle to device independent bitmap (DIB).

Parameters:
result - [out] is a handle to DIB.
hdc - [in] is a handle to the DC of source DDBitmap.
bitmapInfo - [in] describes source DDBitmap.
colorModel - [in] is the type of color model.
ppvBits - [out] is a pointer to the location of bits in DIB section.
hSection - [in] is a hable to DIB section.
dwOffset - [in] is an offset of bits location in DIB section.

getBitCount

public int getBitCount()
Returns the number of bits per pixel.

Returns:
the number of bits per pixel.

setTransparentMask

protected void setTransparentMask(java.awt.Image transparentMask)
Sets transparency mask using input image.

Parameters:
transparentMask - - an image

getTransparentMask

public Bitmap getTransparentMask()
Returns transparancy bitmap mask.

Returns:
bitmap Bitmap instance

isTransparent

public boolean isTransparent()
Returns true if a transparent bitmap.

Returns:
true if a transparent bitmap.

deleteObject

public void deleteObject()
Deletes the object.

Overrides:
deleteObject in class GdiObject

toImage

public java.awt.image.BufferedImage toImage()
Converts windows Bitmap to BufferedImage.

Returns:
image BufferedImage instance.

getBytesCount

protected static int getBytesCount(int height,
                                   int width,
                                   int bitPerPixel)
Return number of bytes in bitmap

Parameters:
height - - number of lines
width - - number of rows
bitPerPixel - - number of bits on pixel
Returns:
- number of bytes

getBitmapLineLength

public int getBitmapLineLength()
Return number of pixels in line. BITMAP standard requires all lines to be aligned on 4-bytes boundary (@see BMP file format ) This method returns aligned line length.

Returns:
Bytes count in each bitmap line

saveToFile

public void saveToFile(java.lang.String fileName)
                throws java.io.IOException
Saves bitmap to the specified file.

Parameters:
fileName - path to the file where the bitmap will be saved.
Throws:
java.io.IOException

getBitmapInfoHeader

public abstract BitmapInfoHeader getBitmapInfoHeader()

getBitmapInfo

public abstract BitmapInfo getBitmapInfo()

loadFromFile

public abstract void loadFromFile(java.lang.String fileName)

getDIBytes

public abstract com.jniwrapper.PrimitiveArray getDIBytes()
Deprecated. use {#getBytes} method to obtain byte array of image

Returns array of device independent bitmap bytes as PrimitiveArray of UInt8.

Returns:
array of bitmap bytes.

getBytes

public abstract byte[] getBytes()
Returns array of device independent bitmap bytes as byte array.

Returns:
array of bitmap bytes.

setDIBytes

public abstract void setDIBytes(com.jniwrapper.PrimitiveArray bytes)
Sets bytes of the bitmap.

Parameters:
bytes -