例如例如圖片大小為1024x1280馬賽克的大小為12x12,取相鄰點像素rgb的平均值
uj5u.com熱心網友回復:
http://files.cnblogs.com/Imageshop/VB%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86%E6%A8%A1%E6%9D%BF.rar我以前共享的,不過上面這個鏈接不是我的。

uj5u.com熱心網友回復:
看了很就很久都看不懂,不知道那一部分才是uj5u.com熱心網友回復:
http://dongtingyueh.blog.163.com/blog/static/461945320127217563098/uj5u.com熱心網友回復:
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As LongPrivate Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Dim mark As Boolean
Dim color As Long
Dim r As Integer
Dim g As Integer
Dim b As Integer
Dim starttime As Data
Dim endtime As Data
Dim spendtime As Data
Public Function mosaic(Picture1 As PictureBox)
Dim row As Integer
Dim lin As Integer
Dim rl As Integer
Dim ll As Integer
Dim xl As Integer
Dim yl As Integer
Dim k As Integer
Dim j As Integer
Dim X As Integer
Dim Y As Integer
Dim color As Long
Dim r As Integer
Dim b As Integer
row = Int(Picture1.ScaleWidth / 10)
lin = Int(Picture1.ScaleHeight / 10)
rl = Picture1.ScaleWidth Mod 10
ll = Picture1.ScaleHeight Mod 10
For Y = 0 To (lin - 1) * 10 Step 10
For X = 0 To (row - 1) * 10 Step 10
color = GetPixel(Picture1.hdc, X + 5, Y + 5)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 65536) - r) / 256)
For k = 0 To 9
For j = 0 To 9
SetPixel Picture1.hdc, X + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
Next X
If rl <> 0 Then
xl = Picture1.ScaleWidth - rl
color = GetPixel(Picture1.hdc, xl + rl / 2, Y + 5)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 655356) - r) / 256)
For k = 0 To rl - 1
For j = 0 To 9
SetPixel Picture1.hdc, xl + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
End If
Next Y
If ll <> 0 Then
yl = Picture1.ScaleHeight - ll
For X = 0 To (row - 1) * 10 Step 10
color = GetPixel(Picture1.hdc, X + 5, yl + ll / 2)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 65536) - r) / 256)
For k = 0 To 9
For j = 0 To ll - 1
SetPixel Picture1.hdc, X + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
Next X
If rl <> 0 Then
color = GetPixel(Picture1.hdc, xl + rl / 2, yl + ll / 2)
r = color Mod 256
b = (Int(color / 65536))
g = Int((color - (b * 65536) - r) / 256)
For k = 0 To rl - 1
For j = 0 To ll - 1
SetPixel Picture1.hdc, X + k, Y + j, RGB(r, g, b)
Next j
Next k
Picture1.Refresh
End If
End If
endtime = Time
spendtime = endtime - starttime
End Function
Private Sub Command3_Click()
Picture1.AutoRedraw = True
mosaic Picture1
Picture1.AutoRedraw = False
End Sub
這段程式哪里出錯了?
uj5u.com熱心網友回復:
655356 ?!轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/123880.html
標籤:API
