0

my application downloads a bitmap :

public byte[] getUrlImgContent(String urlstring) throws IOException
{
    byte[] imageRaw = null;
    URL url = new URL(urlstring);

    HttpURLConnection urlConnection = (HttpURLConnection) url
            .openConnection();
    urlConnection.setUseCaches(false);
    urlConnection.connect();
    if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK)
    {
        try
        {
            InputStream in = new BufferedInputStream(
                    urlConnection.getInputStream());
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            int c;
            while ((c = in.read()) != -1)
            {
                out.write(c);
            }
            out.flush();

            imageRaw = out.toByteArray();

            urlConnection.disconnect();
            in.close();
            out.close();
        } catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return imageRaw;
    }
    return null;
}

and i'm directly converting it to bitmap and showing it in a zoomable-imageview

the problem : the application crashes if the file size is too big

what should I do to reduce the image's size ? (format : jpg)

0 Answers0