public abstract class GLCapture
extends java.lang.Object
Bitmap. The capture will happen
asynchronously on the GL thread; delivery of the captured pixels will occur
on a separate user thread.
This class takes care of the setup and teardown of the offscreen textures and buffer objects; subclasses are responsible for implementing the rendering code to produce the scene to be captured.
| Modifier and Type | Class and Description |
|---|---|
static interface |
GLCapture.CaptureCallback
Callback for an offscreen capture.
|
| Modifier and Type | Field and Description |
|---|---|
protected int |
height |
protected android.opengl.GLSurfaceView |
view |
protected int |
width |
protected int |
x |
protected int |
y |
| Constructor and Description |
|---|
GLCapture(android.opengl.GLSurfaceView view)
Creates a new instance.
|
GLCapture(android.opengl.GLSurfaceView view,
int x,
int y,
int width,
int height)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
capture(GLCapture.CaptureCallback callback)
Performs an asynchronous capture.
|
static void |
compress(android.graphics.Bitmap bitmap,
int quality,
android.graphics.Bitmap.CompressFormat compressFmt,
java.io.File target,
boolean recycleOnExit)
Compresses a bitmap to a target file.
|
protected abstract void |
draw()
Subclasses should override to perform the GL rendering they want captured
for the callback.
|
protected void |
readPixels(GLCapture.CaptureCallback callback) |
protected final android.opengl.GLSurfaceView view
protected final int x
protected final int y
protected final int width
protected final int height
public GLCapture(android.opengl.GLSurfaceView view)
GLSurfaceView.view - A GLSurfaceView instance. The instance will be used
to queue the offscreen capture on the GL context thread.public GLCapture(android.opengl.GLSurfaceView view,
int x,
int y,
int width,
int height)
view - A GLSurfaceView instance. The instance will be
used to queue the offscreen capture on the GL context
thread.x - The x-coordinate of the region of the frame buffer to
capturey - The y-coordinate of the region of the frame buffer to
capturewidth - The width of the region of the frame buffer to captureheight - The height of the region of the frame buffer to captureprotected abstract void draw()
public final void capture(GLCapture.CaptureCallback callback)
GLCapture.CaptureCallback.onCaptureStarted(GLCapture) when
the capture begins and one of
GLCapture.CaptureCallback.onCaptureComplete(GLCapture, Bitmap) or
GLCapture.CaptureCallback.onCaptureError(GLCapture, Throwable) when the
capture has either completed successfully or terminated due to an error.callback - The callback for the capture. May not be
null.protected void readPixels(GLCapture.CaptureCallback callback)
public static void compress(android.graphics.Bitmap bitmap,
int quality,
android.graphics.Bitmap.CompressFormat compressFmt,
java.io.File target,
boolean recycleOnExit)
throws java.io.IOException
bitmap - A bitmapquality - The quality, 0 for lowest quality,
100 for best qualitycompressFmt - The compression formattarget - The target filerecycleOnExit - true to recycle the bitmap before the
method returns, false otherwise.java.io.IOException - if there is an issue writing the bitmap to a file.