嘿,我可以通过设置像素属性设置图像的颜色,但是当我设置条件 getPixel 时,不会发生错误,但程序卡住了
我把代码放在下面请检查它给我解决方案:
Dim b As Bitmap = New Bitmap("D:\test.bmp")
' Make Image Indexed
Dim nii As New Bitmap(b.Width, b.Height,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
For y As Integer = 0 To nii.Height - 1
For x = 0 To nii.Width - 1
Dim cw As New Color
cw = Color.Black
If nii.GetPixel(x, y) = cw Then
nii.SetPixel(x, y, Red)
End If
Next
Next
PictureBox1.Image = FromFile("D:\test.bmp")
PictureBox2.Image = nii
如果我删除 getPixel 那么程序可以工作,但完整的图像颜色将是红色的。