Skip to content

Commit 4225de9

Browse files
committed
Fix native crash #495
1 parent 2f01ae7 commit 4225de9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/src/main/java/jp/co/cyberagent/android/gpuimage/GPUImageRenderer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,16 @@ public void onPreviewFrame(final byte[] data, final int width, final int height)
161161
runOnDraw(new Runnable() {
162162
@Override
163163
public void run() {
164+
if (imageWidth != width || imageHeight != height) {
165+
glRgbBuffer = null;
166+
glRgbBuffer = IntBuffer.allocate(width * height);
167+
GLES20.glDeleteTextures(1, new int[]{glTextureId}, 0);
168+
glTextureId = NO_IMAGE;
169+
}
164170
GPUImageNativeLibrary.YUVtoRBGA(data, width, height, glRgbBuffer.array());
165171
glTextureId = OpenGlUtils.loadTexture(glRgbBuffer, width, height, glTextureId);
166172

167-
if (imageWidth != width) {
173+
if (imageWidth != width || imageHeight != height) {
168174
imageWidth = width;
169175
imageHeight = height;
170176
adjustImageScaling();

0 commit comments

Comments
 (0)