永发信息网

怎么用VB代码改变图片的像素值

答案:2  悬赏:30  手机版
解决时间 2021-04-05 05:05
  • 提问者网友:容嬷嬷拿针来
  • 2021-04-05 00:34
怎么用VB代码改变图片的像素值
最佳答案
  • 五星知识达人网友:千夜
  • 2021-04-05 01:47
比如将每个像素的RGB值乘以0.5

Private Sub Command1_Click()
For i = 0 To Picture1.Width / 15 - 1
For j = 0 To Picture1.Height / 15 - 1
R = (Picture1.Point(x, y) And &HFF) Mod 256
G = ((Picture1.Point(x, y) And &HFF00) \ &H100) Mod 256
B = ((Picture1.Point(x, y) And &HFF0000) \ &H10000) Mod 256
Picture1.PSet (x, y), RGB(R * 0.5, G * 0.5, B * 0.5)
Next j
xext i
End Sub
全部回答
  • 1楼网友:掌灯师
  • 2021-04-05 02:25
窗体上放上二个PIcturebox
Private Sub Form_Load()
Set Picture1.Picture = LoadPicture("请写入你的图片路径")
Picture1.AutoRedraw = True
Picture1.AutoSize = 1
Picture1.BorderStyle = 0
Picture1.Visible = False
Me.ScaleMode = 3
Picture1.ScaleMode = 3
Picture2.AutoRedraw = True
Picture2.ScaleMode = 3
Picture2.Width = Picture1.ScaleWidth
Picture2.Height = Picture1.ScaleWidth
For i = 0 To Picture1.ScaleWidth
For j = 0 To Picture1.ScaleHeight
Picture2.PSet (i, j), Picture1.Point(i, j) '这个就是VB自带的修改像素值过程可以说巨慢无比
Next
Next
End Sub
个人建义还是用API,GDI的GetDIBits放法+模拟指针,或是GDI+的GdipBitmapLockBits
那样的话代码可能会很多,个人不建义用SetPixelV那个真心也慢。。。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯