Android 下载的图像会自动调整大小
我从服务器下载图像并使用以下代码保存它们:Android 下载的图像会自动调整大小,android,menuitem,Android,Menuitem,我从服务器下载图像并使用以下代码保存它们: private void downloadImages(String[] images, String fileName){ for (int i = 0; i < images.length; i++) { try { url = new URL(images[i]); String outputName = i+fileName; inpu
private void downloadImages(String[] images, String fileName){
for (int i = 0; i < images.length; i++) {
try {
url = new URL(images[i]);
String outputName = i+fileName;
input = url.openConnection().getInputStream();
output = activity.openFileOutput(outputName, Context.MODE_PRIVATE);
int read;
byte[] data = new byte[1024];
while ((read = input.read(data)) != -1){
output.write(data, 0, read);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (output != null)
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
if (input != null)
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
private Drawable[] readMenuImages(){
Drawable[] drawable = new Drawable[myJSONObject.getMenuItems().length];
for(int i=0 ; i < myJSONObject.getMenuItems().length ; i++){
try {
drawable[i]=Drawable.createFromStream(activity.openFileInput(i+activity.getString(R.string.menuItemImgarabicfilename)), "ImageStream");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return drawable;
}
事实上,我不明白发生了什么,也不知道如何解决这个问题
我已经访问了此线程,但它没有帮助
谢谢你的帮助