| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
大量收QQ微信精准粉/交友粉,非诚勿扰千里之行 始于足下
共有 445 人关注过本帖
标题:VFP中图片转换
只看楼主 加入收藏
gzzytxy
Rank: 2
等 级:论坛游民
帖 子:77
专家分:16
注 册:2010-1-26
结帖率:69.7%
  已结贴   问题点数: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

2018-01-11 08:41
吹水佬
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:160
帖 子:6218
专家分:27238
注 册: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: 7Rank: 7Rank: 7
等 级:贵宾
威 望:16
帖 子:492
专家分:661
注 册:2012-2-29
  得分:10 
@吹版,学习啦,谢谢!
2018-01-12 08:24







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

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