public Bitmap capture() throws InterruptedException { final Semaphore waiter = new Semaphore(0); final int width = surfaceView.getMeasuredWidth(); final int height = surfaceView.getMeasuredHeight(); // Take picture on OpenGL thread final Bitmap resultBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); gpuImage.runOnGLThread(new Runnable() { @Override public void run() { GPUImageNativeLibrary.adjustBitmap(resultBitmap); waiter.release(); } }); requestRender(); waiter.acquire(); return resultBitmap; }
Semaphore 锁机制
最新推荐文章于 2022-03-29 21:48:31 发布