org.jagatoo.util.image
Class DirectBufferedImage

java.lang.Object
  extended by java.awt.Image
      extended by java.awt.image.BufferedImage
          extended by org.jagatoo.util.image.DirectBufferedImage
All Implemented Interfaces:
java.awt.image.RenderedImage, java.awt.image.WritableRenderedImage, java.awt.Transparency

public class DirectBufferedImage
extends java.awt.image.BufferedImage

Manager for a greyscale alpha mask which can be used to blend bitmaps onto a surface.

Author:
David Yazel, Marvin Froehlich (aka Qudus) [code cleaning]

Field Summary
static int DIRECT_GRAY
           
static int DIRECT_RGB
           
static int DIRECT_RGBA
           
 
Fields inherited from class java.awt.image.BufferedImage
TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR, TYPE_4BYTE_ABGR_PRE, TYPE_BYTE_BINARY, TYPE_BYTE_GRAY, TYPE_BYTE_INDEXED, TYPE_CUSTOM, TYPE_INT_ARGB, TYPE_INT_ARGB_PRE, TYPE_INT_BGR, TYPE_INT_RGB, TYPE_USHORT_555_RGB, TYPE_USHORT_565_RGB, TYPE_USHORT_GRAY
 
Fields inherited from class java.awt.Image
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Method Summary
 byte[] getBackingStore()
           
static java.awt.image.BufferedImage getCustomRGB(int width, int height)
           
static java.awt.image.BufferedImage getCustomRGBA(int width, int height)
           
static DirectBufferedImage getDirectImageGrey(int width, int height)
           
static DirectBufferedImage getDirectImageRGB(int width, int height)
          Creates a buffered image which is backed by a NIO byte buffer
static DirectBufferedImage getDirectImageRGB(int width, int height, int pixelSize)
          Creates a buffered image which is backed by a NIO byte buffer
static DirectBufferedImage getDirectImageRGB(int width, int height, int pixelSize, byte[] backingStore)
          Creates a buffered image which is backed by a NIO byte buffer
static DirectBufferedImage getDirectImageRGBA(int width, int height)
          Creates a buffered image which is backed by a NIO byte buffer
static DirectBufferedImage getDirectImageRGBA(int width, int height, int pixelSize)
          Creates a buffered image which is backed by a NIO byte buffer
 java.awt.image.WritableRaster getDirectRaster(int width, int height, int pixelBytes, java.nio.ByteBuffer byteBuffer)
          Creates a writable raster which is backed by the specified byteBuffer
 int getDirectType()
           
static java.awt.image.BufferedImage loadDirectImage(java.lang.String name)
           
static java.awt.image.BufferedImage loadDirectImage(java.lang.String name, boolean expectAlpha)
          reads in an image using image io.
static java.awt.image.BufferedImage loadDirectImage(java.net.URL url)
           
static java.awt.image.BufferedImage loadDirectImage(java.net.URL url, boolean expectAlpha)
          reads in an image using image io.
static DirectBufferedImage make(java.awt.image.BufferedImage bi)
           
static DirectBufferedImage make(java.awt.image.BufferedImage bi, boolean expectAlpha)
           
static DirectBufferedImage make(int width, int height, int type)
           
static DirectBufferedImage makeDirectImageRGB(java.awt.image.BufferedImage source)
          Takes the source buffered image and converts it to a buffered image which is backed by a direct byte buffer
static DirectBufferedImage makeDirectImageRGBA(java.awt.image.BufferedImage source)
          takes the source buffered image and converts it to a buffered image which is backed by a direct byte buffer
 void setDirectType(int directType)
           
 
Methods inherited from class java.awt.image.BufferedImage
addTileObserver, coerceData, copyData, createGraphics, flush, getAlphaRaster, getCapabilities, getColorModel, getData, getData, getGraphics, getHeight, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getProperty, getPropertyNames, getRaster, getRGB, getRGB, getSampleModel, getSource, getSources, getSubimage, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTransparency, getType, getWidth, getWidth, getWritableTile, getWritableTileIndices, hasTileWriters, isAlphaPremultiplied, isTileWritable, releaseWritableTile, removeTileObserver, setData, setRGB, setRGB, toString
 
Methods inherited from class java.awt.Image
getAccelerationPriority, getScaledInstance, setAccelerationPriority
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DIRECT_RGB

public static final int DIRECT_RGB
See Also:
Constant Field Values

DIRECT_RGBA

public static final int DIRECT_RGBA
See Also:
Constant Field Values

DIRECT_GRAY

public static final int DIRECT_GRAY
See Also:
Constant Field Values
Method Detail

setDirectType

public void setDirectType(int directType)

getDirectType

public int getDirectType()

make

public static DirectBufferedImage make(int width,
                                       int height,
                                       int type)

getBackingStore

public byte[] getBackingStore()

getDirectRaster

public java.awt.image.WritableRaster getDirectRaster(int width,
                                                     int height,
                                                     int pixelBytes,
                                                     java.nio.ByteBuffer byteBuffer)
Creates a writable raster which is backed by the specified byteBuffer

Parameters:
width - Width of the image
height - Height of the image
pixelBytes - Number of bytes in a pixel, usually 4
byteBuffer - Buffer to use as backing store

getCustomRGB

public static java.awt.image.BufferedImage getCustomRGB(int width,
                                                        int height)

getCustomRGBA

public static java.awt.image.BufferedImage getCustomRGBA(int width,
                                                         int height)

getDirectImageRGB

public static DirectBufferedImage getDirectImageRGB(int width,
                                                    int height)
Creates a buffered image which is backed by a NIO byte buffer


getDirectImageRGB

public static DirectBufferedImage getDirectImageRGB(int width,
                                                    int height,
                                                    int pixelSize)
Creates a buffered image which is backed by a NIO byte buffer


getDirectImageRGB

public static DirectBufferedImage getDirectImageRGB(int width,
                                                    int height,
                                                    int pixelSize,
                                                    byte[] backingStore)
Creates a buffered image which is backed by a NIO byte buffer


getDirectImageGrey

public static DirectBufferedImage getDirectImageGrey(int width,
                                                     int height)

getDirectImageRGBA

public static DirectBufferedImage getDirectImageRGBA(int width,
                                                     int height)
Creates a buffered image which is backed by a NIO byte buffer


getDirectImageRGBA

public static DirectBufferedImage getDirectImageRGBA(int width,
                                                     int height,
                                                     int pixelSize)
Creates a buffered image which is backed by a NIO byte buffer


makeDirectImageRGB

public static DirectBufferedImage makeDirectImageRGB(java.awt.image.BufferedImage source)
Takes the source buffered image and converts it to a buffered image which is backed by a direct byte buffer

Parameters:
source -
Returns:
the DirectBufferedImage

makeDirectImageRGBA

public static DirectBufferedImage makeDirectImageRGBA(java.awt.image.BufferedImage source)
takes the source buffered image and converts it to a buffered image which is backed by a direct byte buffer

Parameters:
source -

make

public static DirectBufferedImage make(java.awt.image.BufferedImage bi)

make

public static DirectBufferedImage make(java.awt.image.BufferedImage bi,
                                       boolean expectAlpha)

loadDirectImage

public static java.awt.image.BufferedImage loadDirectImage(java.lang.String name,
                                                           boolean expectAlpha)
                                                    throws java.io.IOException
reads in an image using image io. It then detects if this is a RGBA or RGB image and converts it to the appropriate direct image. Unfortunly this does mean we are loading a buffered image which is thrown away, but there is no help for that currently.

Parameters:
name -
Throws:
java.io.IOException

loadDirectImage

public static java.awt.image.BufferedImage loadDirectImage(java.lang.String name)
                                                    throws java.io.IOException
Throws:
java.io.IOException

loadDirectImage

public static java.awt.image.BufferedImage loadDirectImage(java.net.URL url,
                                                           boolean expectAlpha)
                                                    throws java.io.IOException
reads in an image using image io. It then detects if this is a RGBA or RGB image and converts it to the appropriate direct image. Unfortunly this does mean we are loading a buffered image which is thrown away, but there is no help for that currently.

Parameters:
url -
expectAlpha -
Throws:
java.io.IOException

loadDirectImage

public static java.awt.image.BufferedImage loadDirectImage(java.net.URL url)
                                                    throws java.io.IOException
Throws:
java.io.IOException