简体   繁体   中英

WP7: How to downscale an image smoothly?

I'm developing a Windows Phone app (for technical reasons it must be WP7). I need to show images that are originally stored as hi-res PNGs, but they are shown at a smaller size. I'm using an <Image> inside a <Grid> with star row heights.

The problem is that the downscaled images look kind of choppy (as if the downscaling algorithm is not good), but I can't seem to find a way to show them smoothly without knowing beforehand the display size of the image and generating a new image programmatically.

Is there a property that I can change so that the app uses a different downscaling algorithm and so the image is only defined in XAML, or am I stuck with having to write logic in the code behind so that the image looks smooth?

Update: I got some screenshots to show the problem.

  1. Just an <Image> inside a <Grid>

断断续续的徽标

  1. An <Image> inside a <ViewBox> inside a <Grid>

带有ViewBox的断断续续徽标

ViewBox can help with scaling, but the algorithm it uses is the same, which is not useful at all to me.

See below post to re-size image this might help you

The Microsoft.Phone assembly includes WriteableBitmap class, SaveJpeg() . The SaveJpeg signature looks like this: You can specify image height and width for scaling.

public static void SaveJpeg(
  this WriteableBitmap bitmap, 
  Stream targetStream, 
  int targetWidth, 
  int targetHeight, 
  int orientation, 
  int quality 
  );

Resizing Images in Windows Phone 7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM