|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object glapp.GLImage
public class GLImage
Loads an image from file, stores pixels as ARGB int array, and RGBA ByteBuffer for use in OpenGL. Can convert images to power-of-2 dimensions for textures.
Static functions are included to load, flip and convert pixel arrays.
napier at potatoland dot org
Field Summary | |
---|---|
int |
h
|
java.nio.ByteBuffer |
pixelBuffer
|
int[] |
pixels
|
int |
textureH
|
int |
textureHandle
|
int |
textureW
|
int |
w
|
Constructor Summary | |
---|---|
GLImage()
|
|
GLImage(java.nio.ByteBuffer gl_pixels,
int w,
int h)
Create GLImage from 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 |
convertImagePixelsARGB(int[] jpixels,
int imgw,
int imgh,
boolean flipVertically)
Copy ARGB pixels to a ByteBuffer without changing the ARGB byte order. |
static java.nio.ByteBuffer |
convertImagePixelsRGBA(int[] jpixels,
int imgw,
int imgh,
boolean flipVertically)
Convert ARGB pixels to a ByteBuffer containing RGBA pixels. |
void |
convertToPowerOf2()
Scale this GLImage so width and height are powers of 2. |
static java.awt.image.BufferedImage |
convertToPowerOf2(java.awt.image.BufferedImage bsrc)
Scale the given BufferedImage to width and height that are powers of two. |
void |
flipPixels()
Flip the image pixels vertically |
static int[] |
flipPixels(int[] imgPixels,
int imgw,
int imgh)
Flip an array of pixels vertically |
static java.awt.image.BufferedImage |
flipY(java.awt.image.BufferedImage bsrc)
Flip the given BufferedImage vertically. |
static int[] |
getImagePixels(java.awt.Image image)
Return the Image pixels in default Java int ARGB format. |
java.nio.ByteBuffer |
getPixelBytes()
return ByteBuffer containing pixels in RGBA format (commmonly used in OpenGL). |
int[] |
getPixelInts()
return int array containing pixels in ARGB format (default Java byte order). |
boolean |
isLoaded()
return true if image has been loaded successfully |
void |
loadImage(java.lang.String imgName)
Load an image from the given filename. |
static void |
savePixelsToPNG(int[] pixels,
int width,
int height,
java.lang.String imageFilename,
boolean flipY)
Save an array of ARGB pixels to a PNG file. |
static java.awt.image.BufferedImage |
scale(java.awt.image.BufferedImage bsrc,
int width,
int height)
Scale the given BufferedImage to the given width and height. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int h
public int w
public java.nio.ByteBuffer pixelBuffer
public int[] pixels
public int textureHandle
public int textureW
public int textureH
Constructor Detail |
---|
public GLImage()
public GLImage(java.lang.String imgName)
imgName
- public GLImage(java.nio.ByteBuffer gl_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 static int[] getImagePixels(java.awt.Image image)
public int[] getPixelInts()
public java.nio.ByteBuffer getPixelBytes()
public static int[] flipPixels(int[] imgPixels, int imgw, int imgh)
imgPixels
- imgw
- imgh
-
public static java.nio.ByteBuffer convertImagePixelsARGB(int[] jpixels, int imgw, int imgh, boolean flipVertically)
public static java.nio.ByteBuffer convertImagePixelsRGBA(int[] jpixels, int imgw, int imgh, boolean flipVertically)
If flipVertically is true, pixels will be flipped vertically (for OpenGL coord system).
public static byte[] convertARGBtoRGBA(int[] jpixels)
jpixels
-
public static java.nio.ByteBuffer allocBytes(byte[] bytearray)
bytearray
-
public void convertToPowerOf2()
public static void savePixelsToPNG(int[] pixels, int width, int height, java.lang.String imageFilename, boolean flipY)
public static java.awt.image.BufferedImage convertToPowerOf2(java.awt.image.BufferedImage bsrc)
public static java.awt.image.BufferedImage scale(java.awt.image.BufferedImage bsrc, int width, int height)
public static java.awt.image.BufferedImage flipY(java.awt.image.BufferedImage bsrc)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |