public class PixelFormatUtil extends Object
All conversion methods are endian independent.
Modifier and Type | Class and Description |
---|---|
static class |
PixelFormatUtil.ComponentMap |
Constructor and Description |
---|
PixelFormatUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
convert(int width,
int height,
ByteBuffer src_bb,
PixelFormat src_fmt,
boolean src_glOriented,
int src_lineStride,
ByteBuffer dst_bb,
PixelFormat dst_fmt,
boolean dst_glOriented,
int dst_lineStride) |
static void |
convert(PixelFormatUtil.ComponentMap cmap,
PixelFormat.Composition dstComp,
Bitstream<ByteBuffer> dstBitStream,
PixelFormat.Composition srcComp,
Bitstream<ByteBuffer> srcBitStream) |
static void |
convert(PixelRectangle src,
ByteBuffer dst_bb,
PixelFormat dst_fmt,
boolean dst_glOriented,
int dst_lineStride) |
static PixelRectangle |
convert(PixelRectangle src,
PixelFormat destFmt,
int ddestStride,
boolean isGLOriented,
boolean destIsDirect) |
static int |
convertToInt32(PixelFormat dst_fmt,
byte r,
byte g,
byte b,
byte a) |
static int |
convertToInt32(PixelFormat dst_fmt,
PixelFormat src_fmt,
ByteBuffer src,
int srcOff) |
static int |
convertToInt32(PixelFormat dest_fmt,
PixelFormat src_fmt,
int src_pixel) |
static int |
find(PixelFormat.CType s,
PixelFormat.CType[] pool,
boolean mapRGB2Y) |
static PixelFormat |
getReversed(PixelFormat fmt)
Returns the
PixelFormat with reversed components of fmt . |
static int |
getShiftedI32(int bytesPerPixel,
byte[] data,
int offset)
Returns shifted bytes from the given
data at given offset
of maximal 4 bytesPerPixel . |
static int |
getShiftedI32(int bytesPerPixel,
ByteBuffer data,
boolean retainDataPos)
Returns shifted bytes from the given
data at current position
of maximal 4 bytesPerPixel . |
static long |
getShiftedI64(int bytesPerPixel,
byte[] data,
int offset)
Returns shifted bytes from the given
data at given offset
of maximal 8 bytesPerPixel . |
static long |
getShiftedI64(int bytesPerPixel,
ByteBuffer data,
boolean retainDataPos)
Returns shifted bytes from the given
data at current position
of maximal 8 bytesPerPixel . |
public static final int find(PixelFormat.CType s, PixelFormat.CType[] pool, boolean mapRGB2Y)
public static int getShiftedI32(int bytesPerPixel, byte[] data, int offset)
data
at given offset
of maximal 4 bytesPerPixel
.bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at position offset
offset
- byte offset of pixel data
startpublic static long getShiftedI64(int bytesPerPixel, byte[] data, int offset)
data
at given offset
of maximal 8 bytesPerPixel
.bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at position offset
offset
- byte offset of pixel data
startpublic static int getShiftedI32(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
data
at current position
of maximal 4 bytesPerPixel
.bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at position offset
retainDataPos
- if true, absolute ByteBuffer.get(int)
is used and the data
position stays unchanged.
Otherwise relative ByteBuffer.get()
is used and the data
position changes.public static long getShiftedI64(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
data
at current position
of maximal 8 bytesPerPixel
.bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at position offset
retainDataPos
- if true, absolute ByteBuffer.get(int)
is used and the data
position stays unchanged.
Otherwise relative ByteBuffer.get()
is used and the data
position changes.public static PixelFormat getReversed(PixelFormat fmt)
PixelFormat
with reversed components of fmt
.
If no reversed PixelFormat
is available, returns fmt
.public static int convertToInt32(PixelFormat dst_fmt, byte r, byte g, byte b, byte a)
public static int convertToInt32(PixelFormat dst_fmt, PixelFormat src_fmt, ByteBuffer src, int srcOff)
public static int convertToInt32(PixelFormat dest_fmt, PixelFormat src_fmt, int src_pixel)
public static PixelRectangle convert(PixelRectangle src, PixelFormat destFmt, int ddestStride, boolean isGLOriented, boolean destIsDirect)
public static void convert(PixelRectangle src, ByteBuffer dst_bb, PixelFormat dst_fmt, boolean dst_glOriented, int dst_lineStride) throws IllegalStateException
src
- dst_bb
- ByteBuffer
sinkdst_fmt
- destination PixelFormat
dst_glOriented
- if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
otherwise origin at top left.dst_lineStride
- line stride in byte-size for destination, i.e. byte count from one line to the next.
Must be >= dst_fmt.comp.bytesPerPixel()
* width
or zero
for default stride.IllegalStateException
IllegalArgumentException
- if src_lineStride
or dst_lineStride
is invalidpublic static void convert(int width, int height, ByteBuffer src_bb, PixelFormat src_fmt, boolean src_glOriented, int src_lineStride, ByteBuffer dst_bb, PixelFormat dst_fmt, boolean dst_glOriented, int dst_lineStride) throws IllegalStateException, IllegalArgumentException
width
- width of the to be converted pixel rectangleheight
- height of the to be converted pixel rectanglesrc_bb
- ByteBuffer
sourcesrc_fmt
- source PixelFormat
src_glOriented
- if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
otherwise origin at top left.src_lineStride
- line stride in byte-size for source, i.e. byte count from one line to the next.
Must be >= src_fmt.comp.bytesPerPixel()
* width
or zero
for default stride.dst_bb
- ByteBuffer
sinkdst_fmt
- destination PixelFormat
dst_glOriented
- if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left,
otherwise origin at top left.dst_lineStride
- line stride in byte-size for destination, i.e. byte count from one line to the next.
Must be >= dst_fmt.comp.bytesPerPixel()
* width
or zero
for default stride.IllegalStateException
IllegalArgumentException
- if src_lineStride
or dst_lineStride
is invalidpublic static void convert(PixelFormatUtil.ComponentMap cmap, PixelFormat.Composition dstComp, Bitstream<ByteBuffer> dstBitStream, PixelFormat.Composition srcComp, Bitstream<ByteBuffer> srcBitStream) throws IllegalStateException, IOException
IllegalStateException
IOException
Copyright 2010 JogAmp Community.