I am having an bitmap image to which I am scaling down again and again . But the problem occurring is that the image quality is decreasing as I am scaling down. What should I do to keep the image quality as it is.
Asked
Active
Viewed 146 times
2 Answers
0
If you need scaled image for saving it somewhere, then scale it just once.
If you want to display scaled image then use matrices instread. For example ImageView
class has a method named setImageMatrix()
.

Dmitry Zaytsev
- 23,650
- 14
- 92
- 146
-
I am having a Bitmap Image.How to use matrix in that?? – Jagdeep Singh Sep 03 '12 at 12:03
-
@JagdeepSingh and what do you want to do with it? Display? Save? – Dmitry Zaytsev Sep 03 '12 at 12:04
-
I am displaying it on the screen and scaling it down again and again by createScaledBitmap(Bitmap, int, int, boolean ) method – Jagdeep Singh Sep 03 '12 at 12:09
-
@JagdeepSingh how do you displaying it? On canvas? On ImageView? – Dmitry Zaytsev Sep 03 '12 at 12:10
-
c.drawBitmap(bi2, (float)image_draw_y, (float)image_draw_x, null); – Jagdeep Singh Sep 03 '12 at 12:42
-
@JagdeepSingh then use c.drawBitmap(Bitmap, Matrix, Paint) instead. – Dmitry Zaytsev Sep 03 '12 at 12:46
-
Sorry, but I don't know how to use matrix bitmap.If you can tell me..i could try. – Jagdeep Singh Sep 04 '12 at 10:56
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16243/discussion-between-dmitry-zaitsev-and-jagdeep-singh) – Dmitry Zaytsev Sep 04 '12 at 11:36
0
It looks like a cumulative problem :)
1) Scale from original (largest) image. 2) I am not shure about algorithm used by Bitmap.scalledBitmat, but it is fast and I think, that it returns first discrete pixel which is near position.
So if you can ceonserve quality you will need to do resizing manualy.
Fo example you have an array with 3. point and you need to rescale to array contains 2. point.
Fist point is calculated as dest[0] = (1*src[0]+0.5*src[1])/1.5.
This is in 1D. you need to make 2D algorithm.

Achiles
- 122
- 5