对于Windows手机应用程序,当我通过滑块调整亮度时,它向右移动时工作正常。但当我回到以前的位置,而不是图像变暗,它变得更亮更明亮。这是我基于像素操作的代码。
private void slider1_ValueChanged(object sender,RoutedPropertyChangedEventArgs e) {
wrBmp = new WriteableBitmap(Image1, null);
for (int i = 0; i < wrBmp.Pixels.Count(); i++)
{
int pixel = wrBmp.Pixels[i];
int B = (int)(pixel & 0xFF); pixel >>= 8;
int G = (int)(pixel & 0xFF); pixel >>= 8;
int R = (int)(pixel & 0xFF); pixel >>= 8;
int A = (int)(pixel);
B += (int)slider1.Value; R += (int)slider1.Value; G += (int)slider1.Value;
if (R > 255) R = 255; if (G > 255) G = 255; if (B > 255) B = 255;
if (R < 0) R = 0; if (G < 0) G = 0; if (B < 0) B = 0;
wrBmp.Pixels[i] = B | (G << 8) | (R << 16) | (A << 24);
}
wrBmp.Invalidate();
Image1.Source = wrBmp;
}
我缺少什么,滑块值是否有任何问题。我像往常一样在手机中使用小图像