我有一个图片框控件,我在其中加载50x160 BMP图像,使用:
Picture1.Picture = LoadPicture(App.Path & "\test.bmp")
加载图片后,我想获得特定像素的颜色:
GetPixel(Picture1.hDC, 0, 0)
Picture1.Point(0, 0)
我尝试过8000像素(显然使用循环),每个函数调用(GetPixel
和Point
)总是返回-1
。我第一次测试它是完美的,现在它神奇地无法工作。
有什么想法吗?
答案 0 :(得分:0)
你确定图片已满载吗?
查看以下项目:
'1 form with
' 1 picturebox: name=Picxture1
Option Explicit
Private Sub Form_Load()
Picture1.Picture = LoadPicture("c:\temp\thieu.jpg")
Caption = CStr(Picture1.Point(0, 0))
End Sub
Private Sub Form_Resize()
Picture1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
Private Sub Picture1_Click()
Caption = CStr(Picture1.Point(0, 0))
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Caption = CStr(Picture1.Point(X, Y))
End Sub
当表单加载时,它会加载图片,并直接在标题中显示0,0的颜色..这是-1,因为图片尚未加载
当您在图片上按下鼠标按钮时,它将显示该坐标的颜色,当您松开按钮(并完成单击)时,它将显示坐标的颜色0,0