台灣最大程式設計社群網站
線上人數
1235
 
會員總數:246274
討論主題:189809
歡迎您免費加入會員
討論區列表 >> VB6 >> vb6+GdipBitmapLockBits
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
vb6+GdipBitmapLockBits
價值 : 10 QP  點閱數:1893 回應數:0
樓主

dihyd
門外漢
0 1
117 0
發送站內信

請教各位前輩

小弟在vb6中要做兩張照片清析度的比較
爬文後得知利用GdipBitmapLockBits & GdipBitmapUnlockBits 能快速取得顏色值做比較
單一張圖片我試出來ok
但是要如何才能同時抓兩張圖的的顏色值做比較呢?
也就是如何分別對兩張圖執行GdipBitmapLockBits & GdipBitmapUnlockBits
我的程式如下...但是會當...
跪求前輩指較


Private Sub Command1_Click()
Dim bitmap1, bitmap2 As Long, Graphics As Long
Dim rc1 As RECTL
Dim rc2 As RECTL
Dim Data1(), Data2() As Long

GdipCreateBitmapFromHBITMAP Picture1.Picture.Handle, 0, bitmap1
GdipGetImageWidth bitmap1, rc1.Right
GdipGetImageHeight bitmap1, rc1.Bottom
ReDim Data1(rc1.Right - 1, rc1.Bottom - 1)
Dim BmpData1 As BitmapData
With BmpData1
.Width = rc1.Right
.Height = rc1.Bottom

.PixelFormat = GpPixelFormat.PixelFormat32bppARGB
.scan0 = VarPtr(Data1(0, 0))
.stride = 4 * CLng(rc1.Right)
End With



GdipCreateBitmapFromHBITMAP Picture2.Picture.Handle, 0, bitmap2
GdipGetImageWidth bitmap2, rc2.Right
GdipGetImageHeight bitmap2, rc2.Bottom
ReDim Data2(rc2.Right - 1, rc2.Bottom - 1)
Dim BmpData2 As BitmapData
With BmpData2
.Width = rc2.Right
.Height = rc2.Bottom

.PixelFormat = GpPixelFormat.PixelFormat32bppARGB
.scan0 = VarPtr(Data2(0, 0))
.stride = 4 * CLng(rc2.Right)
End With
Text5.Text = rc1.Right

GdipBitmapLockBits bitmap1, rc1, ImageLockModeUserInputBuf Or ImageLockModeWrite Or ImageLockModeRead, GpPixelFormat.PixelFormat32bppARGB, BmpData1

Dim i As Long, j As Long
For i = 0 To rc1.Bottom - 1
For j = 0 To rc1.Right - 1
Data1(j, i)
Next
Next



GdipBitmapUnlockBits bitmap1, BmpData1


GdipBitmapLockBits bitmap2, rc2, ImageLockModeUserInputBuf Or ImageLockModeWrite Or ImageLockModeRead, GpPixelFormat.PixelFormat32bppARGB, BmpData2

Dim a As Long, As Long
For a = 0 To rc2.Bottom - 1
For b = 0 To rc2.Right - 1
Data2(b, a)
Next
Next

GdipBitmapUnlockBits bitmap2, BmpData2


GdipCreateFromHDC Picture1.hDC, Graphics
GdipDrawImageRectI Graphics, bitmap1, 0, 0, rc1.Right, rc1.Bottom
GdipDeleteGraphics Graphics

GdipDisposeImage bitmap2
GdipDisposeImage bitmap1
Picture1.Refresh


End Sub


本篇文章發表於2012-03-13 17:20
目前尚無任何回覆
   

回覆
如要回應,請先登入.