求图像马赛克显示的算法

迷图小羔羊 2014-04-15 10:11:51
例如例如图片大小为1024x1280马赛克的大小为12x12,取相邻点像素rgb的平均值
...全文
907 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
迷图小羔羊 2014-04-16
  • 打赏
  • 举报
回复
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long Private 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 这段程序哪里出错了?
Trent1985 2014-04-16
  • 打赏
  • 举报
回复
http://dongtingyueh.blog.163.com/blog/static/461945320127217563098/
赵4老师 2014-04-16
  • 打赏
  • 举报
回复
655356 ?!
迷图小羔羊 2014-04-15
  • 打赏
  • 举报
回复
看了很就很久都看不懂,不知道那一部分才是
laviewpbt 2014-04-15
  • 打赏
  • 举报
回复

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧