标题: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

搜索更多相关主题的帖子: VFP 转换 String Long dll 
2018-01-11 08:41
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册: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: 11Rank: 11Rank: 11Rank: 11
来 自:https://t.me/pump_upp
等 级:贵宾
威 望:67
帖 子:1355
专家分:2534
注 册:2012-2-29
得分:10 
@吹版,学习啦,谢谢!
2018-01-12 08:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-484147-1-1.html




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

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