Created
May 2, 2017 00:54
-
-
Save astarasikov/2ebd216fcafa389174b58c6d9913e397 to your computer and use it in GitHub Desktop.
creating Android GraphicBuffer via Reflection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Class c_GraphicBuffer = Class.forName("android.view.GraphicBuffer"); | |
Log.e(LOG_TAG, "GraphicBuffer " + c_GraphicBuffer); | |
Method GraphicBuffer_create = c_GraphicBuffer.getMethod("create", new Class[] { int.class, int.class, int.class, int.class, }); | |
Log.e(LOG_TAG, "Method GraphicBuffer_create " + GraphicBuffer_create); | |
Object hGraphicBuffer = GraphicBuffer_create.invoke(null, 1920, 1080, 1, 0x3 | 0x30 | 0x100); | |
Log.e(LOG_TAG, "Created GraphicBuffer " + hGraphicBuffer); | |
Method GraphicBuffer_lockCanvas = c_GraphicBuffer.getMethod("lockCanvas", new Class[] {}); | |
Log.e(LOG_TAG, "Method GraphicBuffer_lockCanvas " + GraphicBuffer_lockCanvas); | |
Method GraphicBuffer_unlockCanvasAndPost = c_GraphicBuffer.getMethod("unlockCanvasAndPost", new Class[] {Canvas.class}); | |
Log.e(LOG_TAG, "Method GraphicBuffer_unlockCanvasAndPost " + GraphicBuffer_unlockCanvasAndPost); | |
Canvas canvas = (Canvas)GraphicBuffer_lockCanvas.invoke(hGraphicBuffer); | |
Log.e(LOG_TAG, "Locked Canvas"); | |
GraphicBuffer_unlockCanvasAndPost.invoke(hGraphicBuffer, canvas); | |
Log.e(LOG_TAG, "Unlocked Canvas"); | |
} | |
catch (Exception e) | |
{ | |
Log.e(LOG_TAG, "GraphicBuffer not found, oh.."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment