| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2467 人关注过本帖, 1 人收藏
标题:VFP中图片转换
只看楼主 加入收藏
gzzytxy
Rank: 2
等 级:论坛游民
帖 子:77
专家分:16
注 册:2010-1-26
结帖率:69.7%
收藏(1)
已结贴  问题点数:20 回复次数:2 
VFP中图片转换
请老师指点 我在网上找的下面这段代码怎么使用
Function saveimage2(openfile as String,savefile as string)
lqEncoderClsID_BMP=0h00F47C55041AD3119A730000F81EF32E &&BMP
lqEncoderClsID_JPG=0h01F47C55041AD3119A730000F81EF32E &&JPG
lqEncoderClsID_GIF=0h02F47C55041AD3119A730000F81EF32E &&GIF
lqEncoderClsID_TIF=0h05F47C55041AD3119A730000F81EF32E &&TIF
lqEncoderClsID_PNG=0h06F47C55041AD3119A730000F81EF32E &&PNG
DECLARE Long GdipLoadImageFromFile IN Gdiplus.dll String cFile, Long @ nativeImage
DECLARE Long GdipSaveImageToFile IN Gdiplus.dll Long nativeImage, String cFile, ;
         String EncoderClsID, String EncoderParameters
DECLARE Long GdipDisposeImage IN Gdiplus.dll Long nativeImage
lcInputFile=STRCONV(openfile+CHR(0),5)
lcOutputFile=STRCONV(savefile+CHR(0),5)
lnImage=0
GdipLoadImageFromFile(lcInputFile,@lnImage)
GdipSaveImageToFile(lnImage, lcOutputFile, EVALUATE('lqEncoderClsID_'+UPPER(JUSTEXT(savefile))), NULL)
GdipDisposeImage(lnImage)
ERASE &openfile
Endfunc

搜索更多相关主题的帖子: VFP 转换 String Long dll 
2018-01-11 08:41
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:451
帖 子:10609
专家分:43210
注 册:2014-5-20
收藏
得分:10 
简单示例:
DECLARE LONG GdipLoadImageFromFile IN Gdiplus.dll STRING@, LONG@
DECLARE LONG GdipSaveImageToFile IN Gdiplus.dll LONG, STRING@, STRING@, STRING@
DECLARE LONG GdipDisposeImage IN Gdiplus.dll LONG

inFile  = "C:\TEMP\test.bmp"
outFile = "C:\TEMP\test.jpg"
*outFile = "C:\TEMP\test.gif"
*outFile = "C:\TEMP\test.tif"
*outFile = "C:\TEMP\test.png"
IF _tran(inFile, outFile)
    of = CREATEOBJECT("form")
    of.caption = outFile
    of.addobject("image1", "image")
    of.image1.picture = outFile
    of.image1.visible = .T.
    of.show(1)
ENDIF
RETURN

FUNCTION _tran(inFile, outFile)
    LOCAL hBitmap
    hBitmap = 0
    GdipLoadImageFromFile(STRCONV(inFile+0h00,5), @hBitmap)
    IF hBitmap < 1
        MESSAGEBOX("载入图片 " + inFile + " 失败", "提示")
        RETURN .F.
    ENDIF
    LOCAL cExtName, CLSID
    cExtName = LOWER(JUSTEXT(outFile))
    cCLSID = ICASE(;
        cExtName=="jpg", 0h01,;
        cExtName=="gif", 0h02, ;
        cExtName=="tif", 0h05, ;
        cExtName=="png", 0h06,;
        0h00) + 0hF47C55041AD3119A730000F81EF32E
    GdipSaveImageToFile(hBitmap, STRCONV(outFile+0h00,5), cCLSID, NULL)
    GdipDisposeImage(hBitmap)
    RETURN .T.
ENDFUNC

2018-01-11 11:11
schtg
Rank: 12Rank: 12Rank: 12
来 自:Usa
等 级:贵宾
威 望:67
帖 子:1790
专家分:3409
注 册:2012-2-29
收藏
得分:10 
@吹版,学习啦,谢谢!
2018-01-12 08:24
快速回复:VFP中图片转换
数据加载中...
 
   



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

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