我在这里面临一些问题。我有一个套接字服务器,我的应用程序上传图像。现在,如果我说我有1百万客户,每个1MB的图像,我应该留下1太字节的配置文件图像,这太多了。我正在寻找一种方法来将所有图像文件转换为最大100 kb的大小,是可能的吗?如果是的话,我应该搜索什么?在Android中转换图像
而且也是我从磁盘中选择图像文件,像这样:
File file = new File("storage/sdcard/LifeMatePrivate/ProfileImage
/ProfileImage,imagechange_1,"+imagenamer+".jpg")
但是当你看到它只是prefix.jpg选择图像。有没有办法使用任何扩展名的文件?谢谢。
public void SaveImage(View v){
System.out.println(path);
String Path = path;
//File file=new File("storage/sdcard/Pictures/reza2.jpg");
Bitmap bitmap = BitmapFactory.decodeFile("storage/sdcard/Pictures
/reza2.jpg");
// you can change the format of you image compressed for what do you
want;
//now it is set up to 640 x 960;
Bitmap bmpCompressed = Bitmap.createScaledBitmap(bitmap, 640, 960, true);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
// CompressFormat set up to JPG, you can change to PNG or whatever you
want;
bmpCompressed.compress(CompressFormat.PNG, 100, bos);
// Intent returnIntent = new Intent();
// returnIntent.putExtra("result",Path);
// setResult(RESULT_OK,returnIntent);
// Log.i("Image",path);
finish();
}
这个代码是内部的活动与StartActivityForResult
怎么能我一个1600x1200的图像转换为635x479? – user3694470
你可以使用'Bitmap.createScaledBitmap()'方法 –
'bmpCompressed'是压缩格式的新文件..现在你必须在你上传文件时通过它.. –