V
V
Valery2017-03-27 16:30:51
Java
Valery, 2017-03-27 16:30:51

How to resize a Java image?

Hello, there is a small code that compresses images to a fixed size, I wanted to redo it using inSampleSize, but it didn’t work. Where did I go wrong?

Bitmap bitmap = ((BitmapDrawable) evImage.getDrawable()).getBitmap();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
 /* bitmap = Bitmap.createScaledBitmap(bitmap, 514, 686, false); */
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 20, stream);
byte[] byteArray = stream.toByteArray();
ParseFile imageFile = new ParseFile("image.jpg", byteArray);
eventObj.put(Configs.EVENTS_IMAGE, imageFile);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Odissey Nemo, 2017-07-31
@odissey_nemo

It looks like you've set the zoom out scale, but haven't applied it to any picture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question