0

In my android application i'm using pictures with 600*6000 dimension and the size of 91kb but the pictures won't load in my activity.One of my friends suggested that slicing the picture and then showing it could solve the problem.If it works how could we show the sliced pics in the activity or is there any other way to show the pictures and here is the link
https://www.dropbox.com/s/gvylnns2aiqamyc/sgvg.jpg?dl=0

Armin
  • 71
  • 2
  • 9
  • 2
    "the size of 91kb" -- that is the size **on disk**. 600*6000 pixels will be 14062.5kb (around 14MB) in RAM, for `ARGB_8888`. This is a huge image, one that you may not have heap space for. – CommonsWare Dec 14 '14 at 13:35
  • Why doesn't it load? Errors? Exceptions? You can resize it while loading though. If you just cut it in three you will still have the same problem if you place all slices in memory at the same time. – greenapps Dec 14 '14 at 13:36
  • That image is huge. You will need to scale it down, Plenty of examples on the web for scaling images. – Simon Dec 14 '14 at 13:40
  • have a look here on how to resize an image http://stackoverflow.com/questions/10413659/how-to-resize-image-in-android – Muhammed Refaat Dec 14 '14 at 13:49

1 Answers1

0

Search your logcat, you may found something like this

W/OpenGLRenderer﹕ Bitmap too large to be uploaded into a texture (440×5000, max=4096×4096)

You should resize your image to display.

Or split your image to 600*3000 each and display them in two ImageView.

Sample code for split:

private static List<Bitmap> slideBitmap(Bitmap source) {
        int glMaxTextureSize = GL10.GL_MAX_TEXTURE_SIZE;
        int w = source.getWidth();
        int h = source.getHeight();
        List<Bitmap> bitmaps = new ArrayList<Bitmap>();
        int processedHeight = 0;
        while (h > 0) {
            Bitmap subBitmap = Bitmap.createBitmap(source, 0, processedHeight, w, h < glMaxTextureSize ? h : glMaxTextureSize);
            h -= glMaxTextureSize;
            processedHeight += glMaxTextureSize;
            bitmaps.add(subBitmap);
        }        
        return bitmaps;
    }
Cao Dongping
  • 969
  • 1
  • 12
  • 29