I have an java application allows user to take a photo from his camera and send it to me using a web service, But my problem is while sending the image. The send progress takes long time because image is big so i want to compress image. I have tried to:
1- Use this code:
Bitmap img = BitmapFactory.decodeFile("C:\\test.jpg");
ByteArrayOutputStream streem = new ByteArrayOutputStream();
img.compress(Bitmap.CompressFormat.JPEG, 75, streem);
byte[] b = streem.toByteArray();
But this code is useless in my case because it make image very bad and dosent affect on image size a lot.
2- Search a lot about ways to resize but all results is using BufferedImage. I cant use this type(Class) because it takes a lot of memory size:
private static BufferedImage resizeImage(BufferedImage originalImage, int type)
{
BufferedImage resizedImage = new BufferedImage(new_w, new_h, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, new_w, new_h, null);
g.dispose();
return resizedImage;
}
I want to use Bitmap instead, Any body can help me in my application???