找回密码
 加入
搜索
查看: 5201|回复: 13

怎么调整图片的大小?

[复制链接]
发表于 2008-8-21 12:11:41 | 显示全部楼层 |阅读模式
假如我现在的图片是800*600,我想让AU3来自动调整为1024*768,这个怎么操作?

[ 本帖最后由 redapple2008 于 2008-8-24 00:55 编辑 ]
 楼主| 发表于 2008-8-21 18:56:29 | 显示全部楼层
置顶,期待高手出现。
 楼主| 发表于 2008-8-22 10:47:55 | 显示全部楼层
没有调整图片大小的UDF吗?
 楼主| 发表于 2008-8-22 23:38:37 | 显示全部楼层
继续等待。。。。。。。。。。。。。。。。。。。。
 楼主| 发表于 2008-8-23 20:42:52 | 显示全部楼层
继续等待。。。。。。。。。。。。。。。。。。。。
发表于 2008-8-23 21:03:54 | 显示全部楼层
给你个小工具。没用就丢掉吧。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2008-8-23 22:14:48 | 显示全部楼层
隐约记得好像某个对象可以实现这样的功能。
发表于 2008-8-23 22:34:23 | 显示全部楼层
发表于 2008-8-24 00:03:03 | 显示全部楼层
请参考以下代码,希望对你有帮助。

[au3]#include <GDIPlus.au3>

_ImageResize("C:\WINDOWS\Web\Wallpaper\bliss.bmp", @ScriptDir & "\Bliss.jpg", 400, 300)

Func _ImageResize($sInImage, $sOutImage, $iW, $iH)
    Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0
   
    ;OutFile path, to use later on.
    Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1))
   
    ;OutFile name, to use later on.
    Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1)
   
    ;OutFile extension , to use for the encoder later on.
    Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1))
   
    ; Win api to create blank bitmap at the width and height to put your resized image on.
    $hWnd = _WinAPI_GetDesktopWindow()
    $hDC = _WinAPI_GetDC($hWnd)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH)
    _WinAPI_ReleaseDC($hWnd, $hDC)
   
    ;Start GDIPlus
    _GDIPlus_Startup()
   
    ;Get the handle of blank bitmap you created above as an image
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)
   
    ;Load the image you want to resize.
    $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage)
   
    ;Get the graphic context of the blank bitmap
    $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)
   
    ;Draw the loaded image onto the blank bitmap at the size you want
    _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iW)
   
    ;Get the encoder of to save the resized image in the format you want.
    $CLSID = _GDIPlus_EncodersGetCLSID($Ext)
   
    ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image.
    Do
        $i += 1
    Until (Not FileExists($sOP & $i & "_" & $sOF))
   
    ;Prefix the number to the begining of the output filename
    $sOutImage = $sOP & $i & "_" & $sOF
   
    ;Save the new resized image.
    _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID)
   
    ;Clean up and shutdown GDIPlus.
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_Shutdown()
EndFunc[/au3]

评分

参与人数 1金钱 +1 贡献 +1 收起 理由
redapple2008 + 1 + 1 我很赞同

查看全部评分

 楼主| 发表于 2008-8-24 01:01:46 | 显示全部楼层
谢谢了
你的代码不错。
发表于 2008-8-24 10:18:20 | 显示全部楼层

回复 10# redapple2008 的帖子

不敢居功,这个代码不是我的,我是从官网转过来的。
发表于 2011-4-17 10:07:54 | 显示全部楼层
我用3.3.6.1测试,图被转为黑屏的.不能使用.
发表于 2012-8-22 13:41:06 | 显示全部楼层
最新版的没用 了
发表于 2012-12-13 10:35:55 | 显示全部楼层
v3.3.8.1用此方法转换图片以后,成了一张完全黑屏的图片啊啊啊啊!!!
咋整啊?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 05:30 , Processed in 0.077128 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表