static class WritablePixelFormat.ByteBgra extends WritablePixelFormat<java.nio.ByteBuffer>
WritablePixelFormat.ByteBgra, WritablePixelFormat.ByteBgraPre, WritablePixelFormat.IntArgb, WritablePixelFormat.IntArgbPre
PixelFormat.ByteRgb, PixelFormat.IndexedPixelFormat, PixelFormat.Type
Modifier and Type | Field and Description |
---|---|
(package private) static WritablePixelFormat.ByteBgra |
INSTANCE |
Modifier | Constructor and Description |
---|---|
private |
ByteBgra() |
Modifier and Type | Method and Description |
---|---|
int |
getArgb(java.nio.ByteBuffer buf,
int x,
int y,
int scanlineStride)
Reads pixel data from the buffer at the specified coordinates and
converts it to a 32-bit integer representation of the color in the
INT_ARGB format. |
boolean |
isPremultiplied()
Returns true iff the color components decoded (or encoded) by this
format are pre-multiplied by the alpha component for more efficient
blending calculations.
|
void |
setArgb(java.nio.ByteBuffer buf,
int x,
int y,
int scanlineStride,
int argb)
Stores the appropriate pixel data that represents the specified
32-bit integer representation of a color in the buffer
at the specified coordinates.
|
isWritable
createByteIndexedInstance, createByteIndexedPremultipliedInstance, getByteBgraInstance, getByteBgraPreInstance, getByteRgbInstance, getIntArgbInstance, getIntArgbPreInstance, getType, NonPretoPre, PretoNonPre
static final WritablePixelFormat.ByteBgra INSTANCE
public boolean isPremultiplied()
PixelFormat
isPremultiplied
in class PixelFormat<java.nio.ByteBuffer>
public int getArgb(java.nio.ByteBuffer buf, int x, int y, int scanlineStride)
PixelFormat
INT_ARGB
format.
The 32-bit integer will contain the 4 color components in separate
8-bit fields in ARGB order from the most significant byte to the least
significant byte.
The buffer should be positioned to the start of the pixel data such
that buf.get(0)
would return the pixel information for the
pixel at coordinates (0, 0)
.
The scanlineStride
parameter defines the distance from the pixel
data at the start of one row to the pixel data at the start of the
immediately following row at the next higher Y coordinate. Usually,
scanlineStride
is the same as the width of the image multiplied
by the number of data elements per pixel (1 for the case of the
integer and indexed formats, or 3 or 4 in the case of the byte
formats), but some images may have further padding between rows for
alignment or other purposes.
The color components can be extracted from the returned integer using the following sample code:
int alpha = ((retval >> 24) & 0xff); int red = ((retval >> 16) & 0xff); int green = ((retval >> 8) & 0xff); int blue = ((retval ) & 0xff);
getArgb
in class PixelFormat<java.nio.ByteBuffer>
buf
- the buffer of pixel datax
- the X coordinate of the pixel to be ready
- the Y coordinate of the pixel to be readscanlineStride
- the number of buffer elements between the
start of adjacent pixel rows in the bufferINT_ARGB
pixel formatpublic void setArgb(java.nio.ByteBuffer buf, int x, int y, int scanlineStride, int argb)
WritablePixelFormat
buf.get(0)
would return the pixel information for the
pixel at coordinates (0, 0)
.
The scanlineStride
parameter defines the distance from the pixel
data at the start of one row to the pixel data at the start of the
immediately following row at the next higher Y coordinate. Usually,
scanlineStride
is the same as the width of the image multiplied
by the number of data elements per pixel (1 for the case of the
integer and indexed formats, or 3 or 4 in the case of the byte
formats), but some images may have further padding between rows for
alignment or other purposes.
Color components can be composed into an integer using the following sample code:
int argb = ((alpha << 24) | (red << 16) | (green << 8) | (blue );
setArgb
in class WritablePixelFormat<java.nio.ByteBuffer>
buf
- the buffer of pixel datax
- the X coordinate of the pixel to be ready
- the Y coordinate of the pixel to be readscanlineStride
- the number of buffer elements between the
start of adjacent pixel rows in the bufferargb
- a 32-bit value with the color to be stored in the pixel
in a format similar to the Type.INT_ARGB
pixel format