找回密码
 加入
搜索
查看: 4770|回复: 11

[图形处理] [已解决]怎样让多张图片轮换显示?

[复制链接]
发表于 2011-1-9 19:15:13 | 显示全部楼层 |阅读模式
本帖最后由 KLU3K 于 2011-10-17 01:11 编辑

比如5张jpg,然后让他们每秒显示1张,每张显示2秒?
类似幻灯片,当然如果有渐隐渐现的过度效果就更好了。

高手能否写个例子给我们新手学习一下啊?
发表于 2011-1-10 09:30:44 | 显示全部楼层
那天闲的无聊  做了个屏幕保护类的程序。 你看看吧。
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <file.au3>
HotKeySet ("{ESC}","ExitFunc")
Global $PicPath="D:\照片\数码相机\"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", @DesktopWidth+4, @DesktopHeight+4, -2, -2,$WS_POPUP)
$Pic1 = GUICtrlCreatePic("", -2, -2, @DesktopWidth+4, @DesktopHeight+4)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $PicArray=_FileListToArray($PicPath)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
        ChangePic()
        
WEnd
Func ExitFunc()
        Exit
EndFunc

Func ChangePic()
    Local $rand=Random(1,$PicArray[0],1)
    GUICtrlSetImage($Pic1,$PicPath&$PicArray[$rand])        
        Sleep(2000)
EndFunc

评分

参与人数 1金钱 +30 贡献 +5 收起 理由
KLU3K + 30 + 5

查看全部评分

发表于 2011-1-10 09:48:49 | 显示全部楼层
#include <file.au3>
#include <array.au3>
#include <GDIPlus.au3>

Opt('GUIOnEventMode', 1)

Global $path=@WindowsDir&"\Web\Wallpaper"
Global $jpg=_FileListToArray($path,"*.jpg")
Global $number =2

Dim $w_picctrl = 498, $h_picctrl = 298

$Form1 = GUICreate('循环显示图片', 600, 430, -1, -1, -1, 0x00000010)
GUISetOnEvent(-3, '_Exit')
GUICtrlCreateGraphic(50, 50, $w_picctrl + 2, $h_picctrl + 2)
GUICtrlSetGraphic(-1, 10, 0, 0, $w_picctrl + 2, $h_picctrl + 2)
$pic = GUICtrlCreatePic('', 51, 51, 1, 1)
GUICtrlCreateLabel('图片文件路径:', 50, 355, 90, 17)
$ts_File = GUICtrlCreateLabel('', 140, 355, 400, 17)
GUICtrlCreateLabel('图片原始尺寸:', 50, 370, 90, 17)
$ts_size = GUICtrlCreateLabel('', 140, 370, 200, 17)
GUICtrlCreateLabel('格式(后缀名):', 50, 385, 90, 17)
$ts_hzm = GUICtrlCreateLabel('', 140, 385, 90, 17)

GUISetState()

AdlibRegister("_go",2000)
show($path&"\"&$jpg[1])
WinSetOnTop($Form1, '', 1)

While 1
        Sleep(10)
WEnd

Func _go()
        If $number>$jpg[0] Then $number=1
        show($path&"\"&$jpg[$number])
        $number+=1        
EndFunc

Func _Exit()
        GUIDelete()
        Exit
EndFunc   ;==>_Exit

Func Show($jpg_name)
        Local $imgfile = $jpg_name, $hImage, $h_img
        _GDIPlus_Startup()
        $hImage = _GDIPlus_ImageLoadFromFile($imgfile)
        $w_img = _GDIPlus_ImageGetWidth($hImage)
        $h_img = _GDIPlus_ImageGetHeight($hImage)
        If $w_img * $h_img = 0 Then
                _GDIPlus_Shutdown()
                Return MsgBox(48, @error, '非图片格式', '', $Form1)
        EndIf
        ;GUICtrlSetData($ts, '')
        GUICtrlSetData($ts_size, $w_img & ' x ' & $h_img)
        GUICtrlSetData($ts_File, $imgfile)
        GUICtrlSetData($ts_hzm, StringRegExpReplace($imgfile, '.+\\.+\.', ''))
        Local $kgb = $h_picctrl / $w_picctrl
        Local $kgb1 = $h_img / $w_img
        Local $x_py = 0, $y_py = 0, $hBMP, $hObject
        If $w_img > $w_picctrl Or $h_img > $h_picctrl Then
                If $kgb1 > $kgb Then
                        $h_img = $h_picctrl
                        $w_img = Round(1 / $kgb1 * $h_img)
                        $x_py = ($w_picctrl - $w_img) / 2
                Else
                        $w_img = $w_picctrl
                        $h_img = Round($kgb1 * $w_img)
                        $y_py = ($h_picctrl - $h_img) / 2
                EndIf
        Else
                $x_py = ($w_picctrl - $w_img) / 2
                $y_py = ($h_picctrl - $h_img) / 2
        EndIf
        $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
        $hObject = GUICtrlSendMsg($pic, 0x0172, 0, $hBMP)
        _WinAPI_DeleteObject($hObject)
        _GDIPlus_ImageDispose($hImage)
        _WinAPI_DeleteObject($hBMP)
        _GDIPlus_Shutdown()
        GUICtrlSetPos($pic, 51 + $x_py - 1, 51 + $y_py - 1, $w_img, $h_img)
        GUICtrlSetPos($pic, 51 + $x_py, 51 + $y_py)
EndFunc   ;==>Show

评分

参与人数 1金钱 +30 贡献 +5 收起 理由
KLU3K + 30 + 5

查看全部评分

发表于 2011-1-10 09:50:40 | 显示全部楼层
3mile 发表于 2011-1-10 09:48


3G这是追求尽善尽美吗?
发表于 2011-1-10 10:05:21 | 显示全部楼层
回复 4# 水木子
呵呵,看到AFAN兄的图片居中显示代码,顺手牵羊而已。
发表于 2011-1-10 10:53:47 | 显示全部楼层
学习了,谢谢!
顶一个!!
 楼主| 发表于 2011-1-10 19:37:19 | 显示全部楼层
3mile 的代码运行出错。

lanfengc 的代码不错,就是图片过度太硬了。如果有渐隐渐现就好了。
发表于 2011-1-10 20:33:41 | 显示全部楼层
路过。。。。。。。。。。。
发表于 2011-1-11 13:14:38 | 显示全部楼层
回复 7# KLU3K


    我那纯粹闲的蛋疼才做的, 本来就没想着要完善各种功能。 想要过渡在论坛搜索就可以了,一堆的。
发表于 2011-1-14 16:21:47 | 显示全部楼层
谢谢各位楼主分享,学习了。
发表于 2017-3-20 21:54:00 | 显示全部楼层
也有一定的用处哈
发表于 2017-12-17 18:08:53 | 显示全部楼层
谢谢楼主提供,支持你
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-3-28 17:09 , Processed in 0.089758 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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