|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--GLImage
Loads an Image from file, stores pixels as ARGB int array, and RGBA ByteBuffer. An alternate constructor creates a GLImage from a ByteBuffer containing pixel data.
Static functions are included to load, flip and convert pixel arrays.
napier at potatoland dot org
| Field Summary | |
static int |
SIZE_BYTE
|
| Constructor Summary | |
GLImage()
|
|
GLImage(java.nio.ByteBuffer pixels,
int w,
int h)
Store pixels passed in a ByteBuffer. |
|
GLImage(java.lang.String imgName)
Load pixels from an image file. |
|
| Method Summary | |
static java.nio.ByteBuffer |
allocBytes(byte[] bytearray)
Same function as in GLApp.java. |
static byte[] |
convertARGBtoRGBA(int[] jpixels)
Convert pixels from java default ARGB int format to byte array in RGBA format. |
static java.nio.ByteBuffer |
convertImagePixels(int[] jpixels,
int imgw,
int imgh,
boolean flipVertically)
Convert ARGB pixels to a ByteBuffer containing RGBA pixels. Can be drawn in ORTHO mode using: GL.glDrawPixels(imgW, imgH, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, byteBuffer); If flipVertically is true, pixels will be flipped vertically (for OpenGL coord system). |
void |
flipPixels()
Flip the image pixels vertically |
static int[] |
flipPixels(int[] imgPixels,
int imgw,
int imgh)
Flip an array of pixels vertically |
static byte[] |
getBytesFromFile(java.io.File file)
Given File object, returns the contents of the file as a byte array. |
static byte[] |
getBytesFromFile(java.lang.String filename)
Given name of file, return entire file as a byte array. |
int[] |
getImagePixels()
Return the image pixels in default Java int ARGB format. |
int[] |
getPixelsARGB()
return int array containing pixels in ARGB format (default Java byte order). |
java.nio.ByteBuffer |
getPixelsRGBA()
return ByteBuffer containing pixels in RGBA format (commmonly used in OpenGL). |
boolean |
isLoaded()
return true if image has been loaded successfully |
void |
loadImage(java.lang.String imgName)
Load an image file and hold its width/height. |
static java.awt.Image |
loadImageFromFile_ORIG(java.lang.String imgName)
|
static java.awt.Image |
loadImageFromFile(java.lang.String imgName)
Load an image from file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int SIZE_BYTE
| Constructor Detail |
public GLImage()
public GLImage(java.lang.String imgName)
imgName -
public GLImage(java.nio.ByteBuffer pixels,
int w,
int h)
pixels - w - h - | Method Detail |
public boolean isLoaded()
public void flipPixels()
public void loadImage(java.lang.String imgName)
imgName - public int[] getImagePixels()
public int[] getPixelsARGB()
public java.nio.ByteBuffer getPixelsRGBA()
public static int[] flipPixels(int[] imgPixels,
int imgw,
int imgh)
imgPixels - imgw - imgh -
public static java.nio.ByteBuffer convertImagePixels(int[] jpixels,
int imgw,
int imgh,
boolean flipVertically)
public static byte[] convertARGBtoRGBA(int[] jpixels)
jpixels -
public static java.nio.ByteBuffer allocBytes(byte[] bytearray)
bytearray -
public static java.awt.Image loadImageFromFile(java.lang.String imgName)
imgName - public static java.awt.Image loadImageFromFile_ORIG(java.lang.String imgName)
public static byte[] getBytesFromFile(java.lang.String filename)
filename -
public static byte[] getBytesFromFile(java.io.File file)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||