Quantcast
Channel: WriteableBitmapEx
Viewing all articles
Browse latest Browse all 360

Created Unassigned: PNG rendered incorrectly [21480]

$
0
0
Hi,

I am having trouble rendering PNGs that use Palette as "Color Type". Here is some simple code to reproduce the issue:

```
private async System.Threading.Tasks.Task Fetch()

{

HttpClient httpClient = new HttpClient();

Uri uri = new Uri("http://static.splashnology.com/articles/How-to-Optimize-PNG-and-JPEG-without-Quality-Loss/PNG-Palette.png");

HttpResponseMessage response = await httpClient.GetAsync(uri);

if (response.StatusCode == HttpStatusCode.Ok)

{

try

{

var content = await response.Content.ReadAsBufferAsync();

WriteableBitmap image = await BitmapFactory.New(1, 1).FromStream(content.AsStream());

Rect destination = new Rect(0, 0, image.PixelWidth, image.PixelHeight);

Rect source = new Rect(0, 0, image.PixelWidth, image.PixelHeight);

WriteableBitmap canvas = new WriteableBitmap(image.PixelWidth, image.PixelHeight);

canvas.Blit(destination, image, source);

RadarImage.Source = canvas;

}

catch (Exception e)

{

System.Diagnostics.Debug.WriteLine(e.Message);

System.Diagnostics.Debug.WriteLine(e.StackTrace);

}

}

}
```

If I run that code using Windows Phone 8.1, the image appears using wrong colors. If I do the same test using a PNG that is using RGB as "Color Type", then everything is works fine.

Viewing all articles
Browse latest Browse all 360

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>