android-gpuimage
android-gpuimage copied to clipboard
convertToBitmap() does not draw the picture in full size
The convertToBitmap() does not draw the picture in full size.
The source picture looks like this:
If I use getBitmapWithFilterApplied with or without filters then the image is returned incorrectly drawn.
In the file PixelBuffer.java in the function convertToBitmap an empty image is created in the correct size. After the line GPUImageNativeLibrary.adjustBitmap(bitmap); the picture is unfortunately drawn wrong:
The source image has the width 1777 pixels and height 2666 pixels. Density is 444 DPI.
It has something to do with density. If I set Density to 320, then the picture is almost right, but only almost. On the right is a line with empty pixels.
The problem with the empty line is because of the odd number of width. Why is it so? If the width is 1778, then this line does not exist.
Same Problem here. Setting a Image with an odd number of pixels returns a zoomed in Picture.. setImageBitmap should handle it.
public void setImageBitmap(final Bitmap bitmap, final boolean recycle) {
if (bitmap == null) {
return;
}
runOnDraw(new Runnable() {
@Override
public void run() {
Bitmap resizedBitmap = null;
if (bitmap.getWidth() % 2 == 1) {
resizedBitmap = Bitmap.createBitmap(bitmap.getWidth() + 1, bitmap.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas can = new Canvas(resizedBitmap);
can.drawARGB(0x00, 0x00, 0x00, 0x00);
can.drawBitmap(bitmap, 0, 0, null);
mAddedPadding = 1;
} else {
mAddedPadding = 0;
}
mGLTextureId = OpenGlUtils.loadTexture(
resizedBitmap != null ? resizedBitmap : bitmap, mGLTextureId, recycle);
if (resizedBitmap != null) {
resizedBitmap.recycle();
}
mImageWidth = bitmap.getWidth();
mImageHeight = bitmap.getHeight();
adjustImageScaling();
}
});
}
But its not working. If setImage is not handling that case. What does resizeBitmap and Padding do?
Same problem with me @Aw0k3n . I have just Comment this line of code and it works well.
if (bitmap.getWidth() % 2 == 1) {
resizedBitmap = Bitmap.createBitmap(bitmap.getWidth() + 1, bitmap.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas can = new Canvas(resizedBitmap);
can.drawARGB(0x00, 0x00, 0x00, 0x00);
can.drawBitmap(bitmap, 0, 0, null);
mAddedPadding = 1;
} else {
mAddedPadding = 0;
}
Me too, using GPUImageView when it loads, when it saves the image it's not full size