[已解決]怎样能做到输出JPG文件为800x600呢
本帖最后由 abcd1258 于 2014-11-14 19:44 编辑请教一下大家一个问题,要怎么才能输出JPG文件为800x600大小呢?
在此先谢谢大家。#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 FileCopy($sPathPic, @ScriptDir & "\456\12.jpg", 1) Then
Else
EndIf
Exit
EndSwitch
WEnd输出图片 想加上这段,不知道怎么加。
http://www.autoitx.com/forum.php?mod=viewthread&tid=44623 FileCopy($sPathPic, @ScriptDir & "\456\12.jpg", 1)
换成
_PIC2JPG($sPathPic, @ScriptDir & "\456\12.jpg",800, 600) 回复 3# seniors #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
谢谢你的回答,但我这样还是不行。 #include <GDIPlus.au3> #include
seniors 发表于 2014-11-7 19:12 http://www.autoitx.com/images/common/back.gif
谢谢,已经解决。 回复 6# abcd1258
已解決 請將帖子 標提改為 已解決
页:
[1]