public class PixelFormatUtil extends Object
All conversion methods are endian independent.
Modifier and Type | Class and Description |
---|---|
static interface |
PixelFormatUtil.PixelSink |
static interface |
PixelFormatUtil.PixelSink32
Pixel sink for up-to 32bit.
|
Constructor and Description |
---|
PixelFormatUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
convert32(PixelFormatUtil.PixelSink32 dest32,
ByteBuffer src_bb,
PixelFormat src_fmt,
boolean src_glOriented,
int width,
int height,
int stride_bytes) |
static void |
convert32(PixelFormatUtil.PixelSink32 destInt32,
PixelRectangle src) |
static PixelRectangle |
convert32(PixelRectangle src,
PixelFormat destFmt,
int ddestStride,
boolean isGLOriented,
boolean destIsDirect)
public static int convertToInt32(PixelFormat dest_fmt, PixelFormat src_fmt, final int src_pixel) {
final byte r, g, b, a;
switch(src_fmt) {
case LUMINANCE:
r = (byte) ( src_pixel ); // R
g = r; // G
b = r; // B
a = (byte) 0xff; // A
break;
case RGB888:
r = (byte) ( src_pixel ); // R
g = (byte) ( src_pixel >>> 8 ); // G
b = (byte) ( src_pixel >>> 16 ); // B
a = (byte) 0xff; // A
break;
case BGR888:
b = (byte) ( src_pixel ); // B
g = (byte) ( src_pixel >>> 8 ); // G
r = (byte) ( src_pixel >>> 16 ); // R
a = (byte) 0xff; // A
break;
case RGBA8888:
r = (byte) ( src_pixel ); // R
g = (byte) ( src_pixel >>> 8 ); // G
b = (byte) ( src_pixel >>> 16 ); // B
a = (byte) ( src_pixel >>> 24 ); // A
break;
case ABGR8888:
a = (byte) ( src_pixel ); // A
b = (byte) ( src_pixel >>> 8 ); // B
g = (byte) ( src_pixel >>> 16 ); // G
r = (byte) ( src_pixel >>> 24 ); // R
break;
case ARGB8888:
a = (byte) ( src_pixel ); // A
r = (byte) ( src_pixel >>> 8 ); // R
g = (byte) ( src_pixel >>> 16 ); // G
b = (byte) ( src_pixel >>> 24 ); // B
break;
case BGRA8888:
b = (byte) ( src_pixel ); // B
g = (byte) ( src_pixel >>> 8 ); // G
r = (byte) ( src_pixel >>> 16 ); // R
a = (byte) ( src_pixel >>> 24 ); // A
break;
default:
throw new InternalError("Unhandled format "+src_fmt);
}
return convertToInt32(dest_fmt, r, g, b, a);
}
|
static int |
convertToInt32(PixelFormat dest_fmt,
byte r,
byte g,
byte b,
byte a) |
static int |
convertToInt32(PixelFormat dest_fmt,
PixelFormat src_fmt,
ByteBuffer src,
int srcOff) |
static PixelFormat |
getReversed(PixelFormat fmt)
Returns the
PixelFormat with reversed components of fmt . |
static int |
getValue32(PixelFormat src_fmt,
ByteBuffer src,
int srcOff) |
public static PixelFormat getReversed(PixelFormat fmt)
PixelFormat
with reversed components of fmt
.
If no reversed PixelFormat
is available, returns fmt
.public static int getValue32(PixelFormat src_fmt, ByteBuffer src, int srcOff)
public static int convertToInt32(PixelFormat dest_fmt, byte r, byte g, byte b, byte a)
public static int convertToInt32(PixelFormat dest_fmt, PixelFormat src_fmt, ByteBuffer src, int srcOff)
public static PixelRectangle convert32(PixelRectangle src, PixelFormat destFmt, int ddestStride, boolean isGLOriented, boolean destIsDirect)
public static void convert32(PixelFormatUtil.PixelSink32 destInt32, PixelRectangle src)
public static void convert32(PixelFormatUtil.PixelSink32 dest32, ByteBuffer src_bb, PixelFormat src_fmt, boolean src_glOriented, int width, int height, int stride_bytes)
dest32
- 32bit pixel sinksrc_bb
- src_fmt
- src_glOriented
- if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
otherwise origin at top left.width
- height
- strideInBytes
- stride in byte-size, i.e. byte count from one line to the next.
If zero, stride is set to width * bytes-per-pixel
.
If not zero, value must be >= width * bytes-per-pixel
.stride_bytes
- stride in byte-size, i.e. byte count from one line to the next.
Must be >= src_fmt.bytesPerPixel()
* width.IllegalArgumentException
- if strideInBytes
is invalidCopyright 2010 JogAmp Community.