嗨,我试图在 Windows 手机中使用WriteableBitmapEx,但代码不起作用......我在这做错了什么?
double height = image1.ActualHeight;
double width = image1.ActualWidth;
BitmapImage img = new BitmapImage(new Uri("Tulips.png", UriKind.RelativeOrAbsolute));
BitmapImage newImg = image1.Source as BitmapImage;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
int grayScale = (int)((image1.writeableBmp.GetPixel(j, i).R * 0.3) + (image1.writeableBmp.GetPixel(j, i).G * 0.59) + (image1.GetPixel(j, i).B * 0.11));
Color nc = Color.FromArgb (grayScale, grayScale, grayScale);
newImg.SetPixel(j, i, nc);
}
}