我的应用程序下载位图:
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;
}
我直接将其转换为位图并在zoomable-imageview中显示
问题:如果文件太大,应用程序崩溃
我应该怎么做才能缩小图片尺寸? (格式:jpg)