xiehuahere 发表于 2012-8-5 22:04:51

请教gif透明色问题

本帖最后由 xiehuahere 于 2012-8-6 13:21 编辑

下面两种方法都一样,gif动画刷新的时候看到白色底色,很难看。
如何解决?求指教。

方法一:#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

#NoTrayIcon
Const $SW = @DesktopWidth
Const $SH = @DesktopHeight
Local $Gif = @ScriptDir & '\throbber.gif'
If Not FileExists($Gif) Then Exit MsgBox(48 + 262144, "Warning", "Gif file not found!")
HotKeySet("{ESC}", "_Exit")

$MGUI = GUICreate("", $SW, $SH, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000, $MGUI)
GUISetState()
$subGUI = GUICreate("", 100, 100, -1, -1, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_LAYERED, $MGUI)
$BKcolor = 0xFFFFFF
GUISetBkColor($BKcolor)
_WinAPI_SetLayeredWindowAttributes($subGUI, $BKcolor, 255)
$oIE = ObjCreate('Shell.Explorer.2')
GUICtrlCreateObj($oIE, -10, -14, 165, 160)
$oIE.navigate($Gif)
GUISetState()
Do
        Local $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func _Exit()
        Exit
EndFunc方法二(用AniGIF.ocx):#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>

#NoTrayIcon
Const $SW = @DesktopWidth
Const $SH = @DesktopHeight
FileInstall('AniGIF.ocx', @SystemDir & '\', 1)
RunWait('REGSVR32 /S ' & @SystemDir & '\AniGIF.ocx')
FileInstall('throbber.gif', @TempDir & '\', 1)

$MGUI = GUICreate("", $SW, $SH, 0, 0, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST)
GUISetBkColor(0x000000, $MGUI)
GUISetState()
$mainwindow = GUICreate('ESC退出', @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_LAYERED, $MGUI)
$BKcolor = 0xFFFFFF
GUISetBkColor($BKcolor)
_WinAPI_SetLayeredWindowAttributes($mainwindow, $BKcolor, 255)
GUISetState(@SW_SHOW)
WinSetOnTop($mainwindow, '', 1)
$gif = _Create_GIF_Ctrl(@TempDir & '\throbber.gif', ($SW-100)/2, ($SH-100)/2, 100, 100)

HotKeySet("{ESC}", "_Exit")
Do
        Local $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func _Create_GIF_Ctrl($Gif_File_Name, $Gif_x = 0, $Gif_y = 0, $Gif_w = @DesktopWidth, $Gif_H = @DesktopHeight)
        Local $Obj_gif = ObjCreate("AniGIFCtrl.AniGIF")
        Local $id_ctrl_gif = GUICtrlCreateObj($Obj_gif, $Gif_x, $Gif_y, $Gif_w, $Gif_H)
        $Obj_gif.ReadGIF($Gif_File_Name)
        $Obj_gif.Transparent = True
        $Obj_gif.Speed = 1
        $Obj_gif.Play
        Return $id_ctrl_gif
EndFunc   ;==>_Create_GIF_Ctrl

Func _Exit()
        FileDelete(@TempDir & '\throbber.gif')
        Exit
EndFunc用到的动画文件:
http://www.autoitx.com/attachment.php?aid=MjIzNzV8ZjA2NmRjYzh8MTM0NDE3NTQ1M3xiZTczMnJncEd5WUE5MjBvcCtVWFNJQVFicUtYN2gvZjFPd0RoN2owMjVWN0w3dw%3D%3D&noupdate=yes
页: [1]
查看完整版本: 请教gif透明色问题