legacy.resource.codecs.image
Class NativeImageFormat

java.lang.Object
  extended by legacy.resource.Format
      extended by legacy.resource.codecs.image.NativeImageFormat

public class NativeImageFormat
extends Format

NativeImageFormat.class is the base for image files as reads files as defined
readInt() = width
readInt() = height
readBoolean() = has Alpha
readBoolean() = has Transparency
readInt() = Transparency should be indicated above and -1 is read as indiction of no transparency
readInt()...width times height read a packed in containg RGB in the format AARRGGBB
14bytes+(width*height*4)bytes This is a very simple form as is makes things simpler when reading a image and transcoding it. it is also important to note what is read becomes irrelevent quickly as images are adjusted to suit the active VideoAdapter when read.

Author:
Benjamin Tarrant

Constructor Summary
NativeImageFormat(java.io.InputStream stream)
          Constructor for Image Storage.
 
Method Summary
 int getAlpha(int x, int y)
          getPixel returns a pixels alpha level at the given coordinaters
 int[] getAlphaRegion(int x, int y, int width, int height)
          getAlphaRegion copys an area to a array filled with alpha levels
 int[] getAlphaScanline(int x, int y, int width)
          getAlphaScanline return a copy of this image and allows for after x offset and overrun checking.
 int getHeight()
           
 int getPixel(int x, int y)
          getPixel returns pixel at the given coordinaters
 int[] getPixelRegion(int x, int y, int width, int height)
          getPixelRegion copys an area to a array filled with index colors
 int[] getPixelScanline(int x, int y, int width)
          getPixelScanline return a copy of this image and allows for after x offset and overrun checking.
 int getTransparency()
           
 int getWidth()
           
 boolean hasAlphaMap()
           
 boolean hasTransparency()
           
 void putAlpha(int x, int y, int level)
          putAlpha(int x, int y, int level) places a pixel on the active video buffer
 void putPixel(int x, int y, int color)
          putPixel(int x, int y, int color) places a pixel on the active video buffer
 void putPixel(int x, int y, RGB rgb)
          putPixel(int x, int y, RGB rgb) places a pixel on the active video buffer
 
Methods inherited from class legacy.resource.Format
getFormatLoadLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeImageFormat

public NativeImageFormat(java.io.InputStream stream)
                  throws java.io.IOException
Constructor for Image Storage.

Parameters:
stream - the stram to read.
Throws:
java.io.IOException
Method Detail

getWidth

public int getWidth()

getHeight

public int getHeight()

hasAlphaMap

public boolean hasAlphaMap()

hasTransparency

public boolean hasTransparency()

getTransparency

public int getTransparency()

getPixel

public int getPixel(int x,
                    int y)
getPixel returns pixel at the given coordinaters

Parameters:
x - offset
y - offset
Returns:
indexed color

getAlpha

public int getAlpha(int x,
                    int y)
getPixel returns a pixels alpha level at the given coordinaters

Parameters:
x - offset
y - offset
Returns:
lpha level

getPixelRegion

public int[] getPixelRegion(int x,
                            int y,
                            int width,
                            int height)
getPixelRegion copys an area to a array filled with index colors

Parameters:
x - offset
y - offet
width - bounding width
height - bounding height
Returns:
the index array

getAlphaRegion

public int[] getAlphaRegion(int x,
                            int y,
                            int width,
                            int height)
getAlphaRegion copys an area to a array filled with alpha levels

Parameters:
x - offset
y - offet
width - bounding width
height - bounding height
Returns:
the alpha map array

getPixelScanline

public int[] getPixelScanline(int x,
                              int y,
                              int width)
getPixelScanline return a copy of this image and allows for after x offset and overrun checking. scanline shoud represent a line in an image ie from the horizontal posistion 0 to its width at the verticly y. this method on adds the paramity x to reduce complexities later.

Parameters:
x - offset
y - offset
width - width to read.
Returns:
and array filled in with index colors

getAlphaScanline

public int[] getAlphaScanline(int x,
                              int y,
                              int width)
getAlphaScanline return a copy of this image and allows for after x offset and overrun checking. scanline shoud represent a line in an image ie from the horizontal posistion 0 to its width at the verticly y. this method on adds the paramity x to reduce complexities later.

Parameters:
x - offset
y - offset
width - width to read.
Returns:
and array filled in with alpha levels

putPixel

public void putPixel(int x,
                     int y,
                     int color)
putPixel(int x, int y, int color) places a pixel on the active video buffer

Parameters:
x - coordinate
y - coordinate
color - as pallet index

putAlpha

public void putAlpha(int x,
                     int y,
                     int level)
putAlpha(int x, int y, int level) places a pixel on the active video buffer

Parameters:
x - coordinate
y - coordinate
level - alpha level

putPixel

public void putPixel(int x,
                     int y,
                     RGB rgb)
putPixel(int x, int y, RGB rgb) places a pixel on the active video buffer

Parameters:
x - coordinate
y - coordinate
rgb - color