本文整理汇总了Java中com.jogamp.opengl.util.GLPixelStorageModes类的典型用法代码示例。如果您正苦于以下问题:Java GLPixelStorageModes类的具体用法?Java GLPixelStorageModes怎么用?Java GLPixelStorageModes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GLPixelStorageModes类属于com.jogamp.opengl.util包,在下文中一共展示了GLPixelStorageModes类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readToBufferedImage
import com.jogamp.opengl.util.GLPixelStorageModes; //导入依赖的package包/类
/**
* Stolen from com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage()
*
* JOGL 2.1.2
*/
private static BufferedImage readToBufferedImage(
int x,int y, int width, int height, boolean alpha) throws GLException {
int bufImgType = (alpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR);
int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2ES3.GL_BGR);
// Allocate necessary storage
BufferedImage image = new BufferedImage(width, height, bufImgType);
GLContext glc = GLContext.getCurrent();
GL gl = glc.getGL();
// Set up pixel storage modes
GLPixelStorageModes psm = new GLPixelStorageModes();
psm.setPackAlignment(gl, 1);
// read the BGR values into the image
gl.glReadPixels(x, y, width, height, readbackType,
GL.GL_UNSIGNED_BYTE,
ByteBuffer.wrap(((DataBufferByte) image.getRaster().getDataBuffer()).getData()));
// Restore pixel storage modes
psm.restore(gl);
if( glc.getGLDrawable().isGLOriented() ) {
// Must flip BufferedImage vertically for correct results
ImageUtil.flipImageVertically(image);
}
return image;
}
示例2: writeToTargaFile
import com.jogamp.opengl.util.GLPixelStorageModes; //导入依赖的package包/类
/**
* Takes a fast screenshot of the current OpenGL drawable to a Targa
* file. Requires the OpenGL context for the desired drawable to be
* current. Takes the screenshot from the last assigned read buffer,
* or the OpenGL default read buffer if none has been specified by
* the user (GL_FRONT for single-buffered configurations and GL_BACK
* for double-buffered configurations). This is the fastest
* mechanism for taking a screenshot of an application. Contributed
* by Carsten Weisse of Bytonic Software (http://bytonic.de/).
*
* @param file the file to write containing the screenshot
* @param x the starting x coordinate of the screenshot, measured from the lower-left
* @param y the starting y coordinate of the screenshot, measured from the lower-left
* @param width the width of the desired screenshot area
* @param height the height of the desired screenshot area
* @param alpha whether the alpha channel should be saved. If true,
* requires GL_EXT_abgr extension to be present.
*
* @throws GLException if an OpenGL context was not current or
* another OpenGL-related error occurred
* @throws IOException if an I/O error occurred while writing the
* file
*/
public static void writeToTargaFile(File file,
int x,
int y,
int width,
int height,
boolean alpha) throws GLException, IOException {
if (alpha) {
checkExtABGR();
}
TGAWriter writer = new TGAWriter();
writer.open(file, width, height, alpha);
ByteBuffer bgr = writer.getImageData();
GL gl = GLContext.getCurrentGL();
// Set up pixel storage modes
GLPixelStorageModes psm = new GLPixelStorageModes();
psm.setPackAlignment(gl, 1);
int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR);
// read the BGR values into the image buffer
gl.glReadPixels(x, y, width, height, readbackType,
GL.GL_UNSIGNED_BYTE, bgr);
// Restore pixel storage modes
psm.restore(gl);
// close the file
writer.close();
}
示例3: readToBufferedImage
import com.jogamp.opengl.util.GLPixelStorageModes; //导入依赖的package包/类
/**
* Takes a screenshot of the current OpenGL drawable to a
* BufferedImage. Requires the OpenGL context for the desired
* drawable to be current. Takes the screenshot from the last
* assigned read buffer, or the OpenGL default read buffer if none
* has been specified by the user (GL_FRONT for single-buffered
* configurations and GL_BACK for double-buffered configurations).
* Note that the scanlines of the resulting image are flipped
* vertically in order to correctly match the OpenGL contents, which
* takes time and is therefore not as fast as the Targa screenshot
* function.
*
* @param x the starting x coordinate of the screenshot, measured from the lower-left
* @param y the starting y coordinate of the screenshot, measured from the lower-left
* @param width the width of the desired screenshot area
* @param height the height of the desired screenshot area
* @param alpha whether the alpha channel should be read back. If
* true, requires GL_EXT_abgr extension to be present.
*
* @throws GLException if an OpenGL context was not current or
* another OpenGL-related error occurred
*/
public static BufferedImage readToBufferedImage(int x,
int y,
int width,
int height,
boolean alpha) throws GLException {
int bufImgType = (alpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR);
int readbackType = (alpha ? GL2.GL_ABGR_EXT : GL2GL3.GL_BGR);
if (alpha) {
checkExtABGR();
}
// Allocate necessary storage
BufferedImage image = new BufferedImage(width, height, bufImgType);
GLContext glc = GLContext.getCurrent();
GL gl = glc.getGL();
// Set up pixel storage modes
GLPixelStorageModes psm = new GLPixelStorageModes();
psm.setPackAlignment(gl, 1);
// read the BGR values into the image
gl.glReadPixels(x, y, width, height, readbackType,
GL.GL_UNSIGNED_BYTE,
ByteBuffer.wrap(((DataBufferByte) image.getRaster().getDataBuffer()).getData()));
// Restore pixel storage modes
psm.restore(gl);
if( glc.getGLDrawable().isGLOriented() ) {
// Must flip BufferedImage vertically for correct results
ImageUtil.flipImageVertically(image);
}
return image;
}