网上有很多 可以改变分辨率的 但是……
我的图档是JPG 我想转成JPG 在这边都会出问题
使用 BMP 图档 转 JPG 可以正常
但是 使用 JPG 转 JPG 会出问题
附上 网上找的到的范本…………..
有人可以告诉我 出了什么问题呢 为何 JPG 转 JPG 这些UDF 都不可以用呢??Func _PIC2JPG($sFile, $sFile_new, $new_W, $new_H, $IQUALITY = 100)
_GDIPlus_Startup()
Local $HIMAGE = _GDIPlus_ImageLoadFromFile($sFile)
Local $GIQUALITY = $IQUALITY, $PPARAMS
Local $TPARAMS = _GDIPlus_ParamInit(1)
Local $TDATA = DllStructCreate("int Quality")
Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($HIMAGE)
Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($new_W, $new_H, $hGraphics)
Local $hImage_New = _GDIPlus_ImageGetGraphicsContext($hBmp)
DllStructSetData($TDATA, "Quality", $GIQUALITY)
_GDIPlus_ParamAdd($TPARAMS, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($TDATA))
If IsDllStruct($TPARAMS) Then $PPARAMS = DllStructGetPtr($TPARAMS)
Local $CLSID = _GDIPlus_EncodersGetCLSID("JPG")
_GDIPlus_GraphicsDrawImageRect($hImage_New, $HIMAGE, 0, 0, $new_W, $new_H)
Local $SAVE = _GDIPlus_ImageSaveToFileEx($hBmp, $sFile_new, $CLSID, $PPARAMS)
_GDIPlus_GraphicsDispose($hImage_New)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($HIMAGE)
_GDIPlus_Shutdown()
If $SAVE = False Then Return SetError(1, 0, False)
Return True
EndFunc ;==>_PIC2JPG
Func _PicChangeSize($sFile, $sFile_new, $new_W, $new_H)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
MsgBox(0,"",$hImage)
Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
MsgBox(0,"",$hGraphics)
Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($new_W, $new_H, $hGraphics)
MsgBox(0,"",$hBmp)
Local $hImage_New = _GDIPlus_ImageGetGraphicsContext($hBmp)
_GDIPlus_GraphicsDrawImageRect($hImage_New, $hImage, 0, 0, $new_W, $new_H)
_GDIPlus_ImageSaveToFile($hBmp, $sFile_new)
_GDIPlus_GraphicsDispose($hImage_New)
_GDIPlus_BitmapDispose($hBmp)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
EndFunc ;==>_PicChangeSize
|