0

Hy, why canvas crash me if i make width*height (2500*2500) i am wonder i dont know why :(

java.lang.OutOfMemoryError at android.graphics.Bitmap.nativeCreate(Native Method)

This is small pictures but how can i make if i want to process a biger pictures, or how can i find the maximum border of the canvas max size ? Pleas help and help solve problems. I think the width* hight i cant change, because its opengls problem but i think i cant find the border but i dont know how?

Papi
  • 97
  • 2
  • 9
  • 1
    Have you calculated how large the bitmap for a 2500x2500 ARGB canvas is? Nearly 25MB. More than the heap size on most devices. You will have to reduce you size and/or colour depth. – Simon Sep 28 '13 at 08:33
  • [(Height in pixels) x (length in pixels) x (bit depth)] / 8 / 1024 = image size in kilobytes (KB). – JRowan Sep 28 '13 at 08:39
  • how can i calculate for how much is the larger picture ? (width and height) or how can i slove a problem, pleas help.. – Papi Sep 28 '13 at 08:40
  • http://stackoverflow.com/questions/5350465/android-heap-size-on-different-phones-devices-and-os-versions – JRowan Sep 28 '13 at 08:42
  • in android max size for canvas i want calculate if,. if you want test my app if you write it inside in textbox(2500*2500) it will crash, i want protect it about this crash :( https://play.google.com/store/apps/details?id=com.slikar.slika&hl=sl – Papi Sep 28 '13 at 08:43
  • you have to just check the input and if its too high then give them a toast or something and reset the input – JRowan Sep 28 '13 at 08:45

1 Answers1

1

As I remember Android hardware must at least support 2048x2048.

For OpenGL I used:

int[] maxSize = new int[1];
gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSize, 0);
  • For Nexus 4 it equals to 4096
  • For Sansung 2 it equals to 4096

But sure it should be different from device to device

Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225