-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
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
App crashes while adding big size images #1044
Comments
I want to try working on this |
@codegsaini Hi, I am a teammate of deepoceansame and now we are working on the same project. I consider that I have found the cause of this problem. When I add some large size png format images and try to pick one of the enhancements which shuvashish76 mentions in the question. The crash happens. A similar situation is also found when I simply convert a large size png image to pdf format. When the program tries to display an in the enhancement views, it just simply loads the pictures in Bitmap format like the code here.
It decodes a png image to bitmap but a 7.6MB or just 4MB can hold even 30000x 20000 pixels, which requires huge memory.
or
which is a strange error. And in the convert to pdf part. Maybe it is another bug. When I try to convert a 30000x20000 png image. It will cause this error
This is because it invokes the getInstance method of lib itextpdf. Inside this method, especially for png pictures, it will also load the png image and uncompress the png image to bytes which causes some memory errors. It is a little hard for me to tackle this problem because I am just a noob in android development. I have two ideas to solve it. One is that maybe we can load it as the OS does. Load a compressed picture and when the users want to see some detail, we can display that area dynamically by just loads the pixels in that area. And the second way is that we can just easily ban the pictures that cost too large memory. I will try the first method, but it is a little hard for me to manage it. |
@KOISHI-CHEN You can have some help by these references.
I came across Android Documentation page which has provided the way to efficiently decode bitmaps. As the Android documentation says -
So we need to check if the dimensions of image provided are within the limit of memory. The way to check image dimensions before its memory allocation is also mentioned in documentation -
Setting For example if we only require dimension 780x1200 we can use The method for scaling efficiently is provided in Android Documentation -
And to calculate the
So, instead of decoding actual image directly by- |
我已经收到邮件,谢谢发送
|
Describe your issue here.
App crashed when I tried to add 3 images of 7.1MB, 16.1kB, 5.6MB to a single PDF
Steps to reproduce
Crash logs
Would you like to work on the issue?
Sorry, I'm not a dev.
The text was updated successfully, but these errors were encountered: