vb 取某点rgb值分解后再画在另一张图上
我的代码是这样的,但是不知道为什么就是错误OptionExplicitPrivateSubCommand1_Click()Picture1.AutoSize=TruePi...
我的代码是这样的,但是不知道为什么就是错误
Option Explicit
Private Sub Command1_Click()
Picture1.AutoSize = True
Picture2.AutoSize = True
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Command2_Click()
Dim i, j As Integer
Dim r, g, b As Integer
Dim color As Long
For i = 0 To Picture1.Width
For j = 0 To Picture1.Height
color = Picture1.Point(i, j)
r = (color Mod 65536) Mod 256
g = (color Mod 65536) Mod 256
b = color \ 65536
Picture2.PSet (i, j), RGB(r, g, b)
Next
Next
End Sub
那么如果我设 i = 0 To Picture1.ScaleWidth 时,scalewidth和scaleheight是一个设好的定值还是会根据我取得的图的大小自动变成图的宽和高值呢? 展开
Option Explicit
Private Sub Command1_Click()
Picture1.AutoSize = True
Picture2.AutoSize = True
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Command2_Click()
Dim i, j As Integer
Dim r, g, b As Integer
Dim color As Long
For i = 0 To Picture1.Width
For j = 0 To Picture1.Height
color = Picture1.Point(i, j)
r = (color Mod 65536) Mod 256
g = (color Mod 65536) Mod 256
b = color \ 65536
Picture2.PSet (i, j), RGB(r, g, b)
Next
Next
End Sub
那么如果我设 i = 0 To Picture1.ScaleWidth 时,scalewidth和scaleheight是一个设好的定值还是会根据我取得的图的大小自动变成图的宽和高值呢? 展开
展开全部
Option Explicit
Private Sub Command1_Click()
Picture1.AutoSize = True
Picture2.AutoSize = True
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Command2_Click()
Dim i, j As Integer
Dim r, g, b As Integer
Dim color As Long
For i = 0 To Picture1.ScaleWidth
For j = 0 To Picture1.ScaleHeight
color = Picture1.Point(i, j)
r = (color And &HFF&)
g = (color And &HFF00&) \ 256&
b = (color And &HFF0000) \ 65536
Picture2.PSet (i, j), RGB(r, g, b)
Next j
Next i
Picture2.Refresh
End Sub
这样就可以了
你程序当中取r,g,b分量这里错了
r = (color Mod 65536) Mod 256
g = (color Mod 65536) Mod 256
b = color \ 65536
Picture2.PSet (i, j), RGB(r, g, b)
color = Picture1.Point(i, j)
返回的 color 值 是 &HBBGGRR RR:红色分量,GG:绿色分量,BB:蓝色分量
范围 0-&HFFFFFF
r = (color And &HFF&)
g = (color And &HFF00&) \ 256&
b = (color And &HFF0000) \ 65536
这样就是由颜色值分离出 红 绿 蓝 分量
只要将 属性 ScaleMode 设为 3
ScaleWidth scaleheight 就是图片的实际宽度和高度
图上坐标 从 0到 ScaleWidth-1,0 到 scaleheight -1
Private Sub Command1_Click()
Picture1.AutoSize = True
Picture2.AutoSize = True
Picture1.AutoRedraw = True
Picture2.AutoRedraw = True
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Command2_Click()
Dim i, j As Integer
Dim r, g, b As Integer
Dim color As Long
For i = 0 To Picture1.ScaleWidth
For j = 0 To Picture1.ScaleHeight
color = Picture1.Point(i, j)
r = (color And &HFF&)
g = (color And &HFF00&) \ 256&
b = (color And &HFF0000) \ 65536
Picture2.PSet (i, j), RGB(r, g, b)
Next j
Next i
Picture2.Refresh
End Sub
这样就可以了
你程序当中取r,g,b分量这里错了
r = (color Mod 65536) Mod 256
g = (color Mod 65536) Mod 256
b = color \ 65536
Picture2.PSet (i, j), RGB(r, g, b)
color = Picture1.Point(i, j)
返回的 color 值 是 &HBBGGRR RR:红色分量,GG:绿色分量,BB:蓝色分量
范围 0-&HFFFFFF
r = (color And &HFF&)
g = (color And &HFF00&) \ 256&
b = (color And &HFF0000) \ 65536
这样就是由颜色值分离出 红 绿 蓝 分量
只要将 属性 ScaleMode 设为 3
ScaleWidth scaleheight 就是图片的实际宽度和高度
图上坐标 从 0到 ScaleWidth-1,0 到 scaleheight -1
展开全部
如果由 x 和 y 坐标所引用的点位于 object 之外,Point 方法将返回 -1
你给r,g,b赋值的是什么意思?取余再取余。。。?
你给r,g,b赋值的是什么意思?取余再取余。。。?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要写也是
r = color \ 65536
g = (color mod 65536) \ 256
b =(color mod 65536) mod 256
r = color \ 65536
g = (color mod 65536) \ 256
b =(color mod 65536) mod 256
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询