We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For one of my projects, it was needed to use a bitmap compress to JPEG. I would like to be able to choose the compress format in the toDataURL.
The picture I use is too big, I would like to be able to compress in JPEG.
We could add a new parameter to the toDataURL function. It could be a string param like 'PNG' or 'JPEG'
String toDataURL(int width, int height, string compressionFormat) { Bitmap bitmap = Bitmap.createBitmap( width, height, Bitmap.Config.ARGB_8888); clearChildCache(); drawChildren(new Canvas(bitmap)); clearChildCache(); this.invalidate(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); if(compressionFormat == "jpeg") { bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); }else { bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); } bitmap.recycle(); byte[] bitmapBytes = stream.toByteArray(); return Base64.encodeToString(bitmapBytes, Base64.DEFAULT); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Feature Request
For one of my projects, it was needed to use a bitmap compress to JPEG. I would like to be able to choose the compress format in the toDataURL.
Why it is needed
The picture I use is too big, I would like to be able to compress in JPEG.
Possible implementation
We could add a new parameter to the toDataURL function. It could be a string param like 'PNG' or 'JPEG'
Code sample
The text was updated successfully, but these errors were encountered: