Windows Phone 8 で WriteableBitmap を使用して画像の色を変更しようとしています。基本的に、黒色で背景が透明なアイコン (png) があります。次のように、背景が透明な白色に変換しようとしました。
StreamResourceInfo sri = Application.GetResourceStream(new Uri(value.ToString(), UriKind.Relative));
BitmapImage src = new BitmapImage();
src.SetSource(sri.Stream);
// Get WriteableBitmap
WriteableBitmap bitmap = new WriteableBitmap(src);
// Iterate through each pixel.
for (int x = 0; x < bitmap.Pixels.Length; x++)
{
byte[] actualColorValues = BitConverter.GetBytes(bitmap.Pixels[x]);
byte[] modifiedColorValues = new byte[4];
modifiedColorValues[0] = 255;
modifiedColorValues[1] = 255;
modifiedColorValues[2] = 255;
//opacity
modifiedColorValues[3] = actualColorValues[3];
bitmap.Pixels[x] = BitConverter.ToInt32(modifiedColorValues, 0);
}
// Set Image object, defined in XAML, to the modified bitmap.
return bitmap;
画像は白に変換されますが、特にエッジがわずかに歪んでおり、実際のアイコンとして特にエッジが完全ではありません。それは既知の問題ですか、それとも何か不足していますか?