PDA

View Full Version : کم کردن حجم عکس



mehdiyamani
یک شنبه 16 شهریور 1393, 09:56 صبح
سلام دوستان

من یک عکس با گوشی میگیرم و میخواهم حجم این تصویر رو کم کنم . این کدی هست که استفاده میکنم :


FileOutputStream out = null;
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 3;
Bitmap bitmapOrg = BitmapFactory.decodeFile(file,options);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
double width = bitmapOrg.getWidth();
double height = bitmapOrg.getHeight();
double ratio = 600 / width;
int newheight = (int) (ratio * height);
bitmapOrg = Bitmap.createScaledBitmap(bitmapOrg, 500, newheight,true);
try {
out = new FileOutputStream(file);
bitmapOrg.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (FileNotFoundException e) {
Log.v("this",e.getMessage());
}


جم عکس رو کم میکنه و اندازش هم میاره روی 500 پیکسل ولی حجم عکس هنوز خیلی زیاده . حدود 500 کیلوبایت ، میخواستم ببینم راهی هست که بدون اینکه کیفیت تصویر کمتر از این بشه حجمش رو کمتر کنم ؟
ممنون میشم راهنمایی کنید
با تشکر