VB6.0实现图像像素反转

VB6.0像素反转程序

本代码实现了将 Picture1控件中的图像像素反转后显示在 Picture2 控件中的功能。

Private Sub picrev(ByVal picSource As PictureBox, ByVal picDest As PictureBox)
  Dim x As Long, y As Long
  Dim clr As Long

  ' 设置目标图像大小与源图像一致
  picDest.Width = picSource.Width
  picDest.Height = picSource.Height

  ' 逐像素反转颜色
  For y = 0 To picSource.Height - 1
    For x = 0 To picSource.Width - 1
      ' 获取像素颜色
      clr = picSource.Point(x, y)

      ' 反转颜色通道
      clr = RGB(255 - GetRed(clr), 255 - GetGreen(clr), 255 - GetBlue(clr))

      ' 设置目标图像像素颜色
      picDest.PSet (x, y), clr
    Next x
  Next y
End Sub
rar 文件大小:117.53KB