Top Description Inners Fields Constructors Methods
com.jogamp.nativewindow.util

public Class PixelFormatUtil

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.Arrays, com.jogamp.common.nio.Buffers, com.jogamp.common.util.Bitstream

Pixel Rectangle Utilities.

All conversion methods are endian independent.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private static boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static PixelRectangle
convert(final PixelRectangle src, final PixelFormat destFmt, final int ddestStride, final boolean isGLOriented, final boolean destIsDirect)

public static void
convert(final PixelRectangle src, final ByteBuffer dst_bb, final PixelFormat
destination PixelFormat
dst_fmt
,
final boolean
if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.
dst_glOriented
,
final int
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.
dst_lineStride
)

public static void
convert(final int
width of the to be converted pixel rectangle
width
,
final int
height of the to be converted pixel rectangle
height
,
final ByteBuffer
ByteBuffer source
src_bb
,
final PixelFormat src_fmt, final boolean
if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.
src_glOriented
,
int
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.
src_lineStride
,
final ByteBuffer dst_bb, final PixelFormat
destination PixelFormat
dst_fmt
,
final boolean
if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.
dst_glOriented
,
int
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.
dst_lineStride
)

public static void
convert(final PixelFormatUtil.ComponentMap cmap, final PixelFormat.Composition dstComp, final Bitstream<ByteBuffer> dstBitStream, final PixelFormat.Composition srcComp, final Bitstream<ByteBuffer> srcBitStream)

public static int
convertToInt32(final PixelFormat dst_fmt, final byte r, final byte g, final byte b, final byte a)

public static int
convertToInt32(final PixelFormat dst_fmt, final PixelFormat src_fmt, final ByteBuffer src, int srcOff)

public static int
convertToInt32(final PixelFormat dest_fmt, final PixelFormat src_fmt, final int src_pixel)

public static final int
find(final PixelFormat.CType s, final PixelFormat.CType[] pool, final boolean mapRGB2Y)

public static PixelFormat
getReversed(final PixelFormat fmt)

Returns the PixelFormat with reversed components of fmt.

public static int

Returns:

the shifted 32bit integer value of the pixel
getShiftedI32
(final int
number of bytes per pixel to fetch, a maximum of 4 are allowed
bytesPerPixel
,
final byte[]
byte buffer covering complete pixel at position offset
data
,
final int
byte offset of pixel data start
offset
)

Returns shifted bytes from the given data at given offset of maximal 4 bytesPerPixel.

public static int

Returns:

the shifted 32bit integer value of the pixel
getShiftedI32
(final int
number of bytes per pixel to fetch, a maximum of 4 are allowed
bytesPerPixel
,
final ByteBuffer
byte buffer covering complete pixel at position offset
data
,
final boolean
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.
retainDataPos
)

Returns shifted bytes from the given data at current position of maximal 4 bytesPerPixel.

public static long

Returns:

the shifted 64bit integer value of the pixel
getShiftedI64
(final int
number of bytes per pixel to fetch, a maximum of 4 are allowed
bytesPerPixel
,
final byte[]
byte buffer covering complete pixel at position offset
data
,
final int
byte offset of pixel data start
offset
)

Returns shifted bytes from the given data at given offset of maximal 8 bytesPerPixel.

public static long

Returns:

the shifted 64bit integer value of the pixel
getShiftedI64
(final int
number of bytes per pixel to fetch, a maximum of 4 are allowed
bytesPerPixel
,
final ByteBuffer
byte buffer covering complete pixel at position offset
data
,
final boolean
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.
retainDataPos
)

Returns shifted bytes from the given data at current position of maximal 8 bytesPerPixel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEBUGback to summary
private static boolean DEBUG

Constructor Detail

PixelFormatUtilback to summary
public PixelFormatUtil()

Method Detail

convertback to summary
public static PixelRectangle convert(final PixelRectangle src, final PixelFormat destFmt, final int ddestStride, final boolean isGLOriented, final boolean destIsDirect)
convertback to summary
public static void convert(final PixelRectangle src, final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, final int dst_lineStride) throws IllegalStateException
Parameters
dst_bb:ByteBuffer

ByteBuffer sink

dst_fmt:PixelFormat

destination PixelFormat

dst_glOriented:boolean

if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.

dst_lineStride:int

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.

Exceptions
IllegalArgumentException:
if src_lineStride or dst_lineStride is invalid
convertback to summary
public static void convert(final int width, final int height, final ByteBuffer src_bb, final PixelFormat src_fmt, final boolean src_glOriented, int src_lineStride, final ByteBuffer dst_bb, final PixelFormat dst_fmt, final boolean dst_glOriented, int dst_lineStride) throws IllegalStateException, IllegalArgumentException
Parameters
width:int

width of the to be converted pixel rectangle

height:int

height of the to be converted pixel rectangle

src_bb:ByteBuffer

ByteBuffer source

src_fmt:PixelFormat

source PixelFormat

src_glOriented:boolean

if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.

src_lineStride:int

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

ByteBuffer sink

dst_fmt:PixelFormat

destination PixelFormat

dst_glOriented:boolean

if true, the source memory is laid out in OpenGL's coordinate system, origin at bottom left, otherwise origin at top left.

dst_lineStride:int

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.

Exceptions
IllegalArgumentException:
if src_lineStride or dst_lineStride is invalid
convertback to summary
public static void convert(final PixelFormatUtil.ComponentMap cmap, final PixelFormat.Composition dstComp, final Bitstream<ByteBuffer> dstBitStream, final PixelFormat.Composition srcComp, final Bitstream<ByteBuffer> srcBitStream) throws IllegalStateException, IOException
convertToInt32back to summary
public static int convertToInt32(final PixelFormat dst_fmt, final byte r, final byte g, final byte b, final byte a)
convertToInt32back to summary
public static int convertToInt32(final PixelFormat dst_fmt, final PixelFormat src_fmt, final ByteBuffer src, int srcOff)
convertToInt32back to summary
public static int convertToInt32(final PixelFormat dest_fmt, final PixelFormat src_fmt, final int src_pixel)
findback to summary
public static final int find(final PixelFormat.CType s, final PixelFormat.CType[] pool, final boolean mapRGB2Y)
getReversedback to summary
public static PixelFormat getReversed(final PixelFormat fmt)

Returns the PixelFormat with reversed components of fmt. If no reversed PixelFormat is available, returns fmt.

getShiftedI32back to summary
public static int getShiftedI32(final int bytesPerPixel, final byte[] data, final int offset)

Returns shifted bytes from the given data at given offset of maximal 4 bytesPerPixel.

Parameters
bytesPerPixel:int

number of bytes per pixel to fetch, a maximum of 4 are allowed

data:byte[]

byte buffer covering complete pixel at position offset

offset:int

byte offset of pixel data start

Returns:int

the shifted 32bit integer value of the pixel

getShiftedI32back to summary
public static int getShiftedI32(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos)

Returns shifted bytes from the given data at current position of maximal 4 bytesPerPixel.

Parameters
bytesPerPixel:int

number of bytes per pixel to fetch, a maximum of 4 are allowed

data:ByteBuffer

byte buffer covering complete pixel at position offset

retainDataPos:boolean

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.

Returns:int

the shifted 32bit integer value of the pixel

getShiftedI64back to summary
public static long getShiftedI64(final int bytesPerPixel, final byte[] data, final int offset)

Returns shifted bytes from the given data at given offset of maximal 8 bytesPerPixel.

Parameters
bytesPerPixel:int

number of bytes per pixel to fetch, a maximum of 4 are allowed

data:byte[]

byte buffer covering complete pixel at position offset

offset:int

byte offset of pixel data start

Returns:long

the shifted 64bit integer value of the pixel

getShiftedI64back to summary
public static long getShiftedI64(final int bytesPerPixel, final ByteBuffer data, final boolean retainDataPos)

Returns shifted bytes from the given data at current position of maximal 8 bytesPerPixel.

Parameters
bytesPerPixel:int

number of bytes per pixel to fetch, a maximum of 4 are allowed

data:ByteBuffer

byte buffer covering complete pixel at position offset

retainDataPos:boolean

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.

Returns:long

the shifted 64bit integer value of the pixel

com.jogamp.nativewindow.util back to summary

public Class PixelFormatUtil.ComponentMap

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int[]
dst2src

Contains the source index for each destination index, length is Composition#componentCount() of destination.

pack-priv final boolean
pack-priv final int[]
src2dst

Contains the destination index for each source index, length is Composition#componentCount() of source.

pack-priv final int[]
srcRGBA

Contains the source index of RGBA components.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dst2srcback to summary
pack-priv final int[] dst2src

Contains the source index for each destination index, length is Composition#componentCount() of destination.

hasSrcRGBback to summary
pack-priv final boolean hasSrcRGB
src2dstback to summary
pack-priv final int[] src2dst

Contains the destination index for each source index, length is Composition#componentCount() of source.

srcRGBAback to summary
pack-priv final int[] srcRGBA

Contains the source index of RGBA components.

Constructor Detail

ComponentMapback to summary
public ComponentMap(final PixelFormat.Composition src, final PixelFormat.Composition dst)