#NoTrayIcon
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
GUICreate('123.JPG', 623, 445)
DirCreate(@ScriptDir & "\456")
Local $Button1 = GUICtrlCreateButton('插入',144, 272, 150, 30)
Local $Pic1 = GUICtrlCreatePic('', 128, 24, 337, 185)
Local $Button2 = GUICtrlCreateButton('保存', 336, 272, 150, 30)
Local $sPathPic
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $Button1
$sPathPic = FileOpenDialog('浏览照片', @MyDocumentsDir & '\', '图像文件 (*.jpg;*.bmp)', 1)
GUICtrlSetPos($Pic1, 128, 24, 337, 185)
GUICtrlSetImage($Pic1, $sPathPic)
Case $Button2
If _PIC2JPG($sPathPic, @ScriptDir & "\456\12.jpg", 800, 600) Then
Else
EndIf
Exit
EndSwitch
WEnd
Func _PIC2JPG($sFile, $sFile_new, $new_W, $new_H, $IQUALITY = 100)
_GDIPlus_Startup()
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($new_W, $new_H)
Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $new_W, $new_H)
_GDIPlus_ImageDispose($hImage)
Local $sCLSID = _GDIPlus_EncodersGetCLSID("JPG")
Local $tParams = _GDIPlus_ParamInit(1)
Local $tData = DllStructCreate("int Quality")
Local $pData = DllStructGetPtr($tData)
Local $pParams = DllStructGetPtr($tParams)
DllStructSetData($tData, "Quality", $IQUALITY)
_GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData)
_GDIPlus_ImageSaveToFileEx($hBitmap, $sFile_new, $sCLSID, $pParams)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
EndFunc
谢谢你的回答,但我这样还是不行。