Top Fields Constructors Methods
com.jogamp.opengl.util

public Class PNGPixelRect

extends GenericPixelRect
Class Inheritance
Imports
java.io.BufferedInputStream, .IOException, .InputStream, .OutputStream, java.nio.ByteBuffer, .IntBuffer, com.jogamp.nativewindow.util.Dimension, .DimensionImmutable, .PixelFormat, .PixelRectangle, .PixelFormatUtil, jogamp.opengl.Debug, jogamp.opengl.util.pngj.ImageInfo, .ImageLine, .ImageLineHelper, .PngReader, .PngWriter, jogamp.opengl.util.pngj.chunks.PngChunkPLTE, .PngChunkTRNS, .PngChunkTextVar, com.jogamp.common.nio.Buffers, com.jogamp.common.util.IOUtil

Field Summary

Modifier and TypeField and Description
private static final boolean
private final double[]
Inherited from com.jogamp.nativewindow.util.PixelRectangle.GenericPixelRect:
isGLOrientedpixelformatpixelssizestrideInBytes

Constructor Summary

AccessConstructor and Description
public
PNGPixelRect(final PixelFormat pixelformat, final DimensionImmutable size, final int strideInBytes, final boolean isGLOriented, final ByteBuffer pixels, final double dpiX, final double dpiY)

Creates a PNGPixelRect from data supplied by the end user.

public
PNGPixelRect(final PixelRectangle src, final double dpiX, final double dpiY)

Method Summary

Modifier and TypeMethod and Description
public double[]
getDpi()

Returns the dpi of the image.

private static final int
getPixelLUMToAny(final PixelFormat dest_fmt, final ByteBuffer d, int dOff, final byte lum, final byte alpha)

private static final int
getPixelRGBA8ToAny(final PixelFormat dest_fmt, final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final boolean srcHasAlpha)

private static final int
getPixelRGBSame(final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final int bpp)

public static PNGPixelRect

Returns:

the newly created PNGPixelRect instance
read
(final InputStream
input stream
in
,
final PixelFormat
desired destination PixelFormat incl. conversion, maybe null to use source PixelFormat
ddestFmt
,
final boolean
if true, using a direct NIO buffer, otherwise an array backed buffer
destDirectBuffer
,
final int
used if greater than PNG's stride, otherwise using PNG's stride. Stride is width * bytes-per-pixel.
destMinStrideInBytes
,
final boolean destIsGLOriented)

Reads a PNG image from the specified InputStream.

private int
setPixelRGBA8(final ImageLine line, final int lineOff, final ByteBuffer src, final int srcOff, final int bytesPerPixel, final boolean hasAlpha)

private static void
setPixelRGBA8(final PixelFormat pixelformat, final ImageLine line, final int lineOff, final int srcPix, final int bytesPerPixel, final boolean hasAlpha)

public void
write(final OutputStream outstream, final boolean closeOutstream)

public static void
write(final PixelFormat pixelformat, final DimensionImmutable size, int strideInPixels, final boolean isGLOriented, final IntBuffer pixels, final double dpiX, final double dpiY, final OutputStream outstream, final boolean closeOutstream)

Inherited from com.jogamp.nativewindow.util.PixelRectangle.GenericPixelRect:
getPixelformatgetPixelsgetSizegetStridehashCodeisGLOrientedtoString

Field Detail

DEBUGback to summary
private static final boolean DEBUG
dpiback to summary
private final double[] dpi

Constructor Detail

PNGPixelRectback to summary
public PNGPixelRect(final PixelFormat pixelformat, final DimensionImmutable size, final int strideInBytes, final boolean isGLOriented, final ByteBuffer pixels, final double dpiX, final double dpiY)

Creates a PNGPixelRect from data supplied by the end user. Shares data with the passed ByteBuffer.

Parameters
isGLOriented:boolean

see isGLOriented().

PNGPixelRectback to summary
public PNGPixelRect(final PixelRectangle src, final double dpiX, final double dpiY)

Method Detail

getDpiback to summary
public double[] getDpi()

Returns the dpi of the image.

getPixelLUMToAnyback to summary
private static final int getPixelLUMToAny(final PixelFormat dest_fmt, final ByteBuffer d, int dOff, final byte lum, final byte alpha)
getPixelRGBA8ToAnyback to summary
private static final int getPixelRGBA8ToAny(final PixelFormat dest_fmt, final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final boolean srcHasAlpha)
getPixelRGBSameback to summary
private static final int getPixelRGBSame(final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final int bpp)
readback to summary
public static PNGPixelRect read(final InputStream in, final PixelFormat ddestFmt, final boolean destDirectBuffer, final int destMinStrideInBytes, final boolean destIsGLOriented) throws IOException

Reads a PNG image from the specified InputStream.

Implicitly converts the image to match the desired:

Parameters
in:InputStream

input stream

ddestFmt:PixelFormat

desired destination PixelFormat incl. conversion, maybe null to use source PixelFormat

destDirectBuffer:boolean

if true, using a direct NIO buffer, otherwise an array backed buffer

destMinStrideInBytes:int

used if greater than PNG's stride, otherwise using PNG's stride. Stride is width * bytes-per-pixel.

Returns:PNGPixelRect

the newly created PNGPixelRect instance

setPixelRGBA8back to summary
private int setPixelRGBA8(final ImageLine line, final int lineOff, final ByteBuffer src, final int srcOff, final int bytesPerPixel, final boolean hasAlpha)
setPixelRGBA8back to summary
private static void setPixelRGBA8(final PixelFormat pixelformat, final ImageLine line, final int lineOff, final int srcPix, final int bytesPerPixel, final boolean hasAlpha)
writeback to summary
public void write(final OutputStream outstream, final boolean closeOutstream) throws IOException
writeback to summary
public static void write(final PixelFormat pixelformat, final DimensionImmutable size, int strideInPixels, final boolean isGLOriented, final IntBuffer pixels, final double dpiX, final double dpiY, final OutputStream outstream, final boolean closeOutstream) throws IOException