十豆三大大在不 麻烦问个图片超限问题
表单1个按钮1个IMAGE控件
按钮的click
fn = GETPICT("jpg|bmp|gif", "照片文件")
IF NOT EMPTY(fn) AND FILE(fn)
thisform.image.picture = fn
this.Tag = fn
ENDIF
CFILENAME=ALLTRIM(THISFORM.IMAGE.PICTURE)
Declare Integer GdipLoadImageFromFile In GDIPlus.Dll String wFilename, Integer @nImage
Declare Integer GdipGetImageWidth In GDIPlus Integer img,Integer @ imgwidth
Declare Integer GdipGetImageHeight In GDIPlus Integer img,Integer @ imgheight
Declare Integer GdipDisposeImage In GDIPlus.Dll Long nativeImage
Store 0 To nImage,nWidth,nHeight
GdipLoadImageFromFile(Strconv(CFILENAME+Chr(0),5),@nImage)
GdipGetImageWidth(nImage,@nWidth)
GdipGetImageHeight(nImage,@nHeight)
GdipDisposeImage(nImage)
Set Compatible On
fn = Getpict("jpg
[解决办法]
bmp
[解决办法]
gif", "照片文件")
If Not Empty(fn) And File(fn)
If Fsize(fn)/1024>500
Messagebox('图片大于500K(图片大小:'+Transform(Fsize(fn)/1024)+'K)',48,'信息提示')
Return
Endif
Declare Integer GdipLoadImageFromFile In GDIPlus.Dll String wFilename, Integer @nImage
Declare Integer GdipGetImageWidth In GDIPlus Integer img,Integer @ imgwidth
Declare Integer GdipGetImageHeight In GDIPlus Integer img,Integer @ imgheight
Declare Integer GdipDisposeImage In GDIPlus.Dll Long nativeImage
Store 0 To nImage,nWidth,nHeight
GdipLoadImageFromFile(Strconv(fn+Chr(0),5),@nImage)
GdipGetImageWidth(nImage,@nWidth)
GdipGetImageHeight(nImage,@nHeight)
GdipDisposeImage(nImage)
If (nWidth>nHeight And (nWidth>1024 Or nHeight>768)) Or (nWidth<nHeight And (nWidth>768 Or nHeight>1024))
Messagebox('图片分辨率超限(图片分辨率:'+Transform(nWidth)+'×'+Transform(nHeight)+')',48,'信息提示')
Return
Endif
Thisform.Image.Picture = fn
This.Tag = fn
Endif