开发者

Opacity in images in WPF

开发者 https://www.devze.com 2023-01-09 14:18 出处:网络
开发者_如何学编程How can I detect transparent pixels in an image using WPF so that I know where a user clicks?U don\'t need Image class, it is not design for pixel manipulation. Rater use Bitmap* clas

开发者_如何学编程How can I detect transparent pixels in an image using WPF so that I know where a user clicks?


U don't need Image class, it is not design for pixel manipulation. Rater use Bitmap* class

BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(@"/test.png",UriKind.RelativeOrAbsolute);
bi.EndInit();

an exapmle

Implement public PixelColor[,] GetPixels(BitmapSource source) method and then interate through returned array to find Alpha channel ( a simple loop). Mind that some images does not support transparency and the file vary depends on structure (ARGB, RGBA) etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消