| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 548 人关注过本帖, 1 人收藏
标题:vfp如何用渐进色作图
只看楼主 加入收藏
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:790
专家分:1170
注 册:2021-10-13
收藏
得分:0 
鍥炲 10妤
2024-08-20 10:25
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:790
专家分:1170
注 册:2021-10-13
收藏
得分:0 
网上找到api函数,以及VB代码,但是用改成vfp好像无法运行,主要是trivertex和gradient_rect两个结构无法理解,用一般的方法转成字符串好像不行,有没有人知道的?

VB申明:
*Public Declare Function GradientFillRect Lib "msimg32" Alias "GradientFill" ;
(ByVal hDC As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, ;
pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long

*!*    Public Type TRIVERTEX‘顶点类型
*!*    x As Long
*!*    y As Long
*!*    Red As Integer
*!*    Green As Integer
*!*    Blue As Integer
*!*    Alpha As Integer
*!*    End Type

*!*    Public Type GRADIENT_RECT
*!*    UpperLeft As Long
*!*    LowerRight As Long
*!*    End Type

VFP申明:
Declare integer GradientFillRect IN msimg32 integer, string, integer, string, integer, integer
DECLARE integer GradientFill IN gdi32 integer, string, integer, string, integer, integer
2024-08-20 19:53
nbwww
Rank: 8Rank: 8
等 级:贵宾
威 望:11
帖 子:333
专家分:810
注 册:2021-1-9
收藏
得分:5 
这样试下

DECLARE LONG GradientFillRect IN msimg32 integer, string, integer, string, integer, integer
DECLARE LONG GradientFill IN gdi32 integer, string, integer, string, integer, integer
2024-08-20 20:49
sych
Rank: 6Rank: 6
等 级:侠之大者
威 望:7
帖 子:317
专家分:448
注 册:2019-10-11
收藏
得分:0 
Declare long GradientFill IN msimg32.dll long, string @, long, string @, long, long
DECLARE Long ReleaseDC IN WIN32API  Long hWnd, Long hDc
DECLARE INTEGER GetDC IN win32api INTEGER hwnd
DECLARE INTEGER GetDesktopWindow IN win32api
hDc = GetDC(GetDesktopWindow())
tr=BINTOC(300,"4rs")+BINTOC(300,"4rs")+BINTOC(0,"2s")+BINTOC(0,"2s")+BINTOC(255,"2s")+BINTOC(0,"2s")
tr=tr+BINTOC(500,"4rs")+BINTOC(500,"4rs")+BINTOC(0,"2s")+BINTOC(255,"2s")+BINTOC(0,"2s")+BINTOC(0,"2s")
gr=BINTOC(0,"4rs")+BINTOC(1,"4rs")
GradientFill(hdc,@tr,2,@gr,1,1)
ReleaseDC(0,hdc)

2024-08-20 21:12
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:790
专家分:1170
注 册:2021-10-13
收藏
得分:0 
回复 14楼 sych


我知道错哪里了,掉了2个@ 符号。。。
2024-08-22 15:24
sam_jiang
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:790
专家分:1170
注 册:2021-10-13
收藏
得分:0 
回复 14楼 sych
我想完成在三角形中渐变,但似乎没有成功,提示在dll中找不到入口点
调试时这句出错: GradientFilltriangle(hdc,@cvertex,3,@cg_r,1,2)
我的系统是win7+foxpro 9.0 sp2!

代码如下:

程序代码:
Declare integer GradientFillRect IN msimg32 long, string @, long, string @, long, long
Declare integer GradientFillTriangle in "msimg32" Long, string @, Long, string @, Long, Long
DECLARE integer GradientFill IN msimg32 long, string @, long, string @, long, long
DECLARE integer GetWindowDC IN WIN32API integer
DECLARE integer GetLastError IN WIN32API 
DECLARE integer ReleaseDC IN WIN32API integer,integer
DECLARE INTEGER GetDesktopWindow IN win32api
DECLARE INTEGER GetDC IN win32api INTEGER hwnd

clea
hdc=getdc(_screen.hwnd)
overtex=NEWOBJECT("trivertex")
overtex.n=3
overtex.set(1,100,100)
overtex.set(2,500,500)
overtex.set(3,50,400)
cvertex=overtex.getstruct()

og_r=NEWOBJECT("gradient_rect")
og_r.n=3
og_r.set(1,0,1,2)
cg_r=og_r.getstruct()

GradientFilltriangle(hdc,@cvertex,3,@cg_r,1,2)
RELEASE memo like o*
RELEASE memo like c*
releasedc(_screen.hwnd,hdc)

**************************************************
*-- 类:           trivertex (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 父类:  struct (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 基类:    custom
*-- 时间戳:   08/22/24 05:03:08 PM
*
DEFINE CLASS trivertex AS custom


    Height = 22
    Width = 58

    *-- 顶点数,决定所有数组大小,2为矩形,3为三角形,大于3则可以任意组合。
    n = .F.

    *-- 顶点x轴坐标数组
    DIMENSION x[2]

    *-- 顶点y轴坐标数组
    DIMENSION y[2]

    *-- 红色分量数组
    DIMENSION r[2]

    *-- 绿色分量数组
    DIMENSION g[2]

    *-- 蓝色分量数组
    DIMENSION b[2]

    *-- alpha透明度分量数组
    DIMENSION a[2]


    PROCEDURE n_assign
        LPARAMETERS vNewVal
        *To do: 为 Assign 方法程序修改此例程
        IF m.vnewval<>this.n
            DIMENSION this.x[m.vnewval]
            DIMENSION this.y[m.vnewval]
            DIMENSION this.r[m.vnewval]
            DIMENSION this.g[m.vnewval]
            DIMENSION this.b[m.vnewval]
            DIMENSION this.a[m.vnewval]
        ENDIF
        THIS.n = m.vNewVal
    ENDPROC


    PROCEDURE getstruct
        this.struct=''
        FOR i=1 TO this.n
            this.struct=this.struct+;
                BINTOC(this.x[i],[4rs])+;
                BINTOC(this.y[i],[4rs])+;
                BINTOC(this.r[i],[2s])+;
                BINTOC(this.g[i],[2s])+;
                BINTOC(this.b[i],[2s])+;
                BINTOC(this.a[i],[2s])
        ENDFOR

        RETURN this.struct
    ENDPROC


    PROCEDURE set
        *!*********    在设置顶点结构前,需要确定有几个顶点,this.n=? **********!*
        PARAMETERS nindex, x,y,nred,ngreen,nblue,nalpha
        DO CASE 
            CASE PARAMETERS()=3
                ocolor=NEWOBJECT([color],[myclass])
                ncolor=GETCOLOR()
                IF ncolor<0
                    RELEASE ocolor,ncolor
                    RETURN .f.
                ELSE
                    ocolor.set(ncolor)
                    this.x[nindex]=x
                    this.y[nindex]=y
                    this.r[nindex]=ocolor.r
                    this.g[nindex]=ocolor.g
                    this.b[nindex]=ocolor.b
                    this.a[nindex]=ocolor.a
                ENDIF
            CASE PARAMETERS()=7
                this.x[nindex]=x
                this.y[nindex]=y
                this.r[nindex]=nred
                this.g[nindex]=ngreen
                this.b[nindex]=nblue
                this.a[nindex]=nalpha
            OTHERWISE 
                RETURN .f.
        ENDCASE 

    ENDPROC


ENDDEFINE
*
*-- EndDefine: trivertex
**************************************************


**************************************************
*-- 类:           gradient_rect (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 父类:  struct (d:\documents\visual foxpro 项目\myclass.vcx)
*-- 基类:    custom
*-- 时间戳:   08/22/24 07:58:02 PM
*
DEFINE CLASS gradient_rect AS custom


    *-- 确定矩形或三角形顶点的数量,总是2的倍数(长方形),或3的倍数(三角形)
    n = 2

    *-- 指定顶点结构数组中的索引数组
    DIMENSION nindexs[2]


    PROCEDURE n_assign
        LPARAMETERS vNewVal
        *To do: 为 Assign 方法程序修改此例程
        *事实上矩形的数量可能多于顶点数/2,可能几个矩形共用某个顶点
        IF m.vnewval<>this.n
            DIMENSION this.nindexs[m.vnewval]
        ENDIF
        THIS.n = m.vNewVal
    ENDPROC


    PROCEDURE getstruct
        this.struct=''
        IF ASCAN(this.nindexs,.f.)!=0
            MESSAGEBOX('有未定义的索引!')
        ELSE
            FOR i=1 TO ALEN(this.nindexs)
                this.struct=this.struct+BINTOC(this.nindexs[i],"4rs")
            ENDFOR
        ENDIF

        RETURN this.struct
    ENDPROC


    PROCEDURE set
        PARAMETERS ngroup,nindex1,nindex2,nindex3
        DO CASE
            CASE PARAMETERS()=3 && 说明是矩形
                IF ngroup<=this.n
                    this.nindexs[ngroup*2-1]=nindex1
                    this.nindexs[ngroup*2]=nindex2
                ELSE
                    RETURN .f.
                ENDIF

            CASE PARAMETERS()=4 && 说明是三角形
                IF ngroup<=this.n
                    this.nindexs[ngroup*3-2]=nindex1
                    this.nindexs[ngroup*3-1]=nindex2
                    this.nindexs[ngroup*3]=nindex3
                ELSE
                    RETURN .f.
                ENDIF
            OTHERWISE
            RETURN .f.
        ENDCASE
    ENDPROC


ENDDEFINE
*
*-- EndDefine: gradient_rect
**************************************************



[此贴子已经被作者于2024-8-22 20:15编辑过]

2024-08-22 20:09
快速回复:vfp如何用渐进色作图
数据加载中...
 
   



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

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