| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1324 人关注过本帖
标题:颜色填充解决方案
只看楼主 加入收藏
建生65
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2018-5-10
结帖率:100%
收藏
 问题点数:0 回复次数:0 
颜色填充解决方案
上一个帖子的解决方案:
Option Explicit
Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Dim X0, Y0 As Double
Dim X(1 To 5), Y(1 To 5) As Double
Dim Xtop0, Ytop0, Xbot0, Ybot0 As Double
Private Sub tianchong()
    Dim i As Integer
    Dim Xhalf, Yhalf As Double
    Dim Kx, Ky As Double
    Dim Xpixel(1 To 5), Ypixel(1 To 5) As Double
   
    Picture1.ScaleMode = 3
    Picture1.AutoRedraw = True
    Picture1.ForeColor = vbRed
    Picture1.FillColor = vbBlack
    Picture1.FillStyle = 0
   
    Kx = Picture1.Width / (Xbot0 - Xtop0)
    Ky = Picture1.Height / (Ybot0 - Ytop0)
   
    Xpixel(1) = Kx * X(1): Ypixel(1) = Ky * Y(1)
    Xpixel(2) = Kx * X(2): Ypixel(2) = Ky * Y(2)
    Xpixel(3) = Kx * X(3): Ypixel(3) = Ky * Y(3)
    Xpixel(4) = Kx * X(4): Ypixel(4) = Ky * Y(4)
    Xpixel(5) = Kx * X(5): Ypixel(5) = Ky * Y(5)
   
'    For i = 1 To 5
'        MsgBox Xpixel(i): MsgBox Ypixel(i)
'    Next i
'    MsgBox Picture1.Width: MsgBox Picture1.Height
   
    Picture1.Line (Xpixel(1), Ypixel(1))-(Xpixel(2), Ypixel(2))
    Picture1.Line -(Xpixel(3), Ypixel(3))
    Picture1.Line -(Xpixel(4), Ypixel(4))
    Picture1.Line -(Xpixel(5), Ypixel(5))
    Picture1.Line -(Xpixel(1), Ypixel(1))
'
    X0 = (Xpixel(1) + Xpixel(2) + Xpixel(3) + Xpixel(4) + Xpixel(5)) / 5
    Y0 = (Ypixel(1) + Ypixel(2) + Ypixel(3) + Ypixel(4) + Ypixel(5)) / 5
    MsgBox X0: MsgBox Y0
    Call ExtFloodFill(Picture1.hdc, X0, Y0, vbRed, 0)
   
End Sub

Private Sub Form_Load()
    Xtop0 = 0: Ytop0 = 0
    Xbot0 = 100: Ybot0 = 100
    Form1.ScaleMode = 3
    X(1) = 20: Y(1) = 20
    X(2) = 40: Y(2) = 20
    X(3) = 60: Y(3) = 30
    X(4) = 40: Y(4) = 40
    X(5) = 20: Y(5) = 40
    Call tianchong
    Picture1.Scale (Xtop0, Ytop0)-(Xbot0, Ybot0)
    Picture1.Line (40, 40)-(50, 50), RGB(255, 0, 0)
End Sub

图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: Long Dim Double MsgBox Line 
2018-05-17 19:09
快速回复:颜色填充解决方案
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016874 second(s), 11 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved