user1120998
user1120998

Reputation: 229

Drawing App--Filling Color Saved as BitmapImage in Windows Phone7

I am doing a Drawing App. I have saved the color fill image as bitmapImage in collection. Again I open the saved image for drawing. If i fill the color of image, the color filling not clear. I have used ExtensionJpg for save Image.

            WriteableBitmap pBitmap;
            pBitmap = new WriteableBitmap(imgDraw, null); // imgDraw is jpg image bitmapImage binded to source. 

            BitmapImage img1 = new BitmapImage();
            MemoryStream ms = new MemoryStream();
            pBitmap.SaveJpeg(ms, (int)pBitmap.PixelWidth, (int)pBitmap.PixelHeight, 0, 100);                  
            img1.SetSource(ms);

In this case again i have binded the this bitmap Image to imgDraw Source. But to saw the image is very clear. When i fill colors to imgDraw is not applied correctly.

Thanks

Upvotes: 1

Views: 225

Answers (1)

Emond
Emond

Reputation: 50682

When you encode a bitmap as a Jpeg file you can lose data. that is part of the design of lossy compression algorithms such as Jpeg.

Even worse, using a lossy compression can introduce (hardly visible) artifacts. So by saving the image as Jpeg you are probably adding pixels to the large, clear area. These pixels cause the fill to fail.

You have three options:

  1. Do not use a lossy algorithm by switching to e.g. PNG
  2. Change the quality of the compression
  3. Change the fill algorithm to be more tolerant of nearly-the-same-color pixels.

I noticed that you set the quality to 100 but this question makes me doubt the quality of the jpeg implementation of the method you might be using. You could switch to PNG to see if that helps.

Upvotes: 2

Related Questions