Sunday, January 22, 2012

[android-developers] Re: Image Quality problems using Canvas and canvas.scale(Scale, Scale);

At the risk of stating the bleeding obvious, if you upscale a bitmap
*anywhere* in your code by a factor which is not an exact integer (1,
2, 3, etc) then the system will not be able to exactly reproduce the
original image, and will be interpolating and/or duplicating pixels to
make it fit. Which gives you a not so great result.

You have gone to great lengths to avoid scaling when you read it in
(using Bitmap Factory Options), this is largely a waste of time if you
scale it for writing using canvas.scale. You will still get scaling
artefacts on write. You need to suppress scaling for read *and* write.

The only way that I know of to get pinsharp graphics - with your
bitmaps appearing exactly how you intended - is to write to a canvas
which has the same resolution as the actual device (or View). The
downside of this is that you have to manage all possible screen
resolutions within your code, as you can no longer use the system to
map a fixed co-ordinate space in your code to the specs of the actual
screen. A pretty obvious trade-off between coding simplicity and image
quality.

If you are already relying on automatic output scaling for lots of
other stuff in your code, you are probably stuck with it.


Peter Webb

On Jan 22, 2:15 pm, JamesColeman <JamesCole...@RadicalPhotography.com>
wrote:
> I am having Image Quality problems using Canvas and
> canvas.scale(Scale, Scale); they look exactly like the following:
>
> http://stackoverflow.com/questions/2041207/android-quality-of-the-ima...
>
> I believe I have read all the posts on image quality problems when re-
> sizing bitmaps, but it doesn't seem to help when scaling with a Canvas
> scale(float scale).
>
> I have tried many different options as suggested by the image quality
> posts.
>
> BitmapFactory.Options options = new BitmapFactory.Options();
> options.inJustDecodeBounds = false;
> options.inDither = false;
> options.inSampleSize = 1;
> options.inScaled = false;
> options.inPreferredConfig = Bitmap.Config.ARGB_8888;//I thought this
> would do it
> CurrentPicture = BitmapFactory.decodeFile(path, options);//Also tried
> decodeStream()
>
> PicturePaint = new Paint();
> //PicturePaint = new Paint(Paint.FILTER_BITMAP_FLAG); //I also tried
> this
> //PicturePaint = new Paint(Paint.ANTI_ALIAS_FLAG);  //I also tried
> this
> canvas.scale(Scale, Scale);
> canvas.drawBitmap(CurrentPicture, 0, 0, PicturePaint);
>
> I am quite concerned as I am in serious trouble if I can't get the
> image quality problem solved. Any help is appreciated.
>
> Thanks!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate