加载图像和转换图像的像素颜色
问题描述:
如何使用C#加载图像和转换图像的像素颜色
这里来改变图像的像素颜色和更新的图像在WP7,我已经装在IMG1源一个JPG图像。我想将该图像加载到writableBitmap并转换像素颜色。我试过了,但我得到了一张空白的图像。
WriteableBitmap writeableBmp = new WriteableBitmap(512, 512);
writeableBmp.Render(img1, null);
for (int i = 0; i < 500; i++)
{
writeableBmp.Pixels.SetValue(21, i);
}
img1.Source = writeableBmp;
答
您可以从使用JPG图像转换的BitmapImage创建可写位图。
然后更改值并指定给Image控件如下。
请检查是否解决了您的问题。
BitmapImage bmp = new BitmapImage(new Uri("JpegImageUri", UriKind.RelativeOrAbsolute));
WriteableBitmap wbmp = new WriteableBitmap(bmp);
for (int i = 0; i < 500; i++)
{
wbmp.Pixels.SetValue(21, i);
}
Image image = new Image();
image.Source = wbmp;