Package com.jogamp.nativewindow.util
Class PixelFormatUtil
- java.lang.Object
-
- com.jogamp.nativewindow.util.PixelFormatUtil
-
public class PixelFormatUtil extends Object
Pixel Rectangle Utilities.All conversion methods are endian independent.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PixelFormatUtil.ComponentMap
-
Constructor Summary
Constructors Constructor Description PixelFormatUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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 PixelRectangle
convert(PixelRectangle src, PixelFormat destFmt, int ddestStride, boolean isGLOriented, boolean destIsDirect)
static void
convert(PixelRectangle src, ByteBuffer dst_bb, PixelFormat dst_fmt, boolean dst_glOriented, int dst_lineStride)
static int
convertToInt32(PixelFormat dst_fmt, byte r, byte g, byte b, byte a)
static int
convertToInt32(PixelFormat dest_fmt, PixelFormat src_fmt, int src_pixel)
static int
convertToInt32(PixelFormat dst_fmt, PixelFormat src_fmt, ByteBuffer src, int srcOff)
static int
find(PixelFormat.CType s, PixelFormat.CType[] pool, boolean mapRGB2Y)
static PixelFormat
getReversed(PixelFormat fmt)
Returns thePixelFormat
with reversed components offmt
.static int
getShiftedI32(int bytesPerPixel, byte[] data, int offset)
Returns shifted bytes from the givendata
at givenoffset
of maximal 4bytesPerPixel
.static int
getShiftedI32(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
Returns shifted bytes from the givendata
at current position of maximal 4bytesPerPixel
.static long
getShiftedI64(int bytesPerPixel, byte[] data, int offset)
Returns shifted bytes from the givendata
at givenoffset
of maximal 8bytesPerPixel
.static long
getShiftedI64(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
Returns shifted bytes from the givendata
at current position of maximal 8bytesPerPixel
.
-
-
-
Method Detail
-
find
public static final int find(PixelFormat.CType s, PixelFormat.CType[] pool, boolean mapRGB2Y)
-
getShiftedI32
public static int getShiftedI32(int bytesPerPixel, byte[] data, int offset)
Returns shifted bytes from the givendata
at givenoffset
of maximal 4bytesPerPixel
.- Parameters:
bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at positionoffset
offset
- byte offset of pixeldata
start- Returns:
- the shifted 32bit integer value of the pixel
-
getShiftedI64
public static long getShiftedI64(int bytesPerPixel, byte[] data, int offset)
Returns shifted bytes from the givendata
at givenoffset
of maximal 8bytesPerPixel
.- Parameters:
bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at positionoffset
offset
- byte offset of pixeldata
start- Returns:
- the shifted 64bit integer value of the pixel
-
getShiftedI32
public static int getShiftedI32(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
Returns shifted bytes from the givendata
at current position of maximal 4bytesPerPixel
.- Parameters:
bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at positionoffset
retainDataPos
- if true, absoluteByteBuffer.get(int)
is used and thedata
position stays unchanged. Otherwise relativeByteBuffer.get()
is used and thedata
position changes.- Returns:
- the shifted 32bit integer value of the pixel
-
getShiftedI64
public static long getShiftedI64(int bytesPerPixel, ByteBuffer data, boolean retainDataPos)
Returns shifted bytes from the givendata
at current position of maximal 8bytesPerPixel
.- Parameters:
bytesPerPixel
- number of bytes per pixel to fetch, a maximum of 4 are alloweddata
- byte buffer covering complete pixel at positionoffset
retainDataPos
- if true, absoluteByteBuffer.get(int)
is used and thedata
position stays unchanged. Otherwise relativeByteBuffer.get()
is used and thedata
position changes.- Returns:
- the shifted 64bit integer value of the pixel
-
getReversed
public static PixelFormat getReversed(PixelFormat fmt)
Returns thePixelFormat
with reversed components offmt
. If no reversedPixelFormat
is available, returnsfmt
.
-
convertToInt32
public static int convertToInt32(PixelFormat dst_fmt, byte r, byte g, byte b, byte a)
-
convertToInt32
public static int convertToInt32(PixelFormat dst_fmt, PixelFormat src_fmt, ByteBuffer src, int srcOff)
-
convertToInt32
public static int convertToInt32(PixelFormat dest_fmt, PixelFormat src_fmt, int src_pixel)
-
convert
public static PixelRectangle convert(PixelRectangle src, PixelFormat destFmt, int ddestStride, boolean isGLOriented, boolean destIsDirect)
-
convert
public static void convert(PixelRectangle src, ByteBuffer dst_bb, PixelFormat dst_fmt, boolean dst_glOriented, int dst_lineStride) throws IllegalStateException
- Parameters:
src
-dst_bb
-ByteBuffer
sinkdst_fmt
- destinationPixelFormat
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 orzero
for default stride.- Throws:
IllegalStateException
IllegalArgumentException
- ifsrc_lineStride
ordst_lineStride
is invalid
-
convert
public 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
- Parameters:
width
- width of the to be converted pixel rectangleheight
- height of the to be converted pixel rectanglesrc_bb
-ByteBuffer
sourcesrc_fmt
- sourcePixelFormat
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 orzero
for default stride.dst_bb
-ByteBuffer
sinkdst_fmt
- destinationPixelFormat
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 orzero
for default stride.- Throws:
IllegalStateException
IllegalArgumentException
- ifsrc_lineStride
ordst_lineStride
is invalid
-
convert
public static void convert(PixelFormatUtil.ComponentMap cmap, PixelFormat.Composition dstComp, Bitstream<ByteBuffer> dstBitStream, PixelFormat.Composition srcComp, Bitstream<ByteBuffer> srcBitStream) throws IllegalStateException, IOException
- Throws:
IllegalStateException
IOException
-
-