小编Fli*_*nta的帖子

C# 如何从拉伸位图/图片框中获取像素

好的,我有一个带有图像的图片框,其 sizeMode 设置为:StretchImage,
现在,我想获取我单击的像素。(位图。GetPixel(x,y))。
但是当图像从正常尺寸拉伸时,我得到原始像素。就像在拉伸之前存在的像素一样(如果这有意义?)

我的代码:

Private void pictureBox1_MouseUp(object sender, MouseEventArgs e) {
  Bitmap img = (Bitmap)pictureBox1.Image; 
  var color = img.GetPixel(e.X, e.Y)
}
Run Code Online (Sandbox Code Playgroud)

提前致谢

c# image bitmap picturebox

1
推荐指数
1
解决办法
1853
查看次数

标签 统计

bitmap ×1

c# ×1

image ×1

picturebox ×1