• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            S.l.e!ep.¢%

            像打了激速一樣,以四倍的速度運轉,開心的工作
            簡單、開放、平等的公司文化;尊重個性、自由與個人價值;
            posts - 1098, comments - 335, trackbacks - 0, articles - 1
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Transparent Flash Control

            Posted on 2009-12-04 17:21 S.l.e!ep.¢% 閱讀(997) 評論(0)  編輯 收藏 引用 所屬分類: VC

            Transparent Flash Control

            Posted on 2008-09-11 22:13 沒畫完的畫 閱讀(1146) 評論(2) ?編輯?收藏引用 所屬分類: Windows COM

            在網頁中只需要加入以下代碼

            <object?classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"?codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"?width="600"?height="60">?
            <param?name="movie"?value="test.swf">?
            <param?name="quality"?value="high">?
            <param?name="wmode"?value="transparent">?
            <embed?src="***.swf"?quality="high"?pluginspage="http://www.macromedia.com/go/getflashplayer"?type="application/x-shockwave-flash"?width="600"?height="60"></embed>?
            </object>?
            就可以實現 Flash 背景透明

            在VC中要實現 Flash 背影透明播放,Google了一下找到一個 Demo
            原文URL:http://www.codeproject.com/KB/COM/flashcontrol.aspx

            需要自己實現一個OLE容器,以前很少接觸COM,現在要實現的是一個OLE容器,先汗一下!!!!
            想到一個問題:自己實現一個OLE容器跟使用直接使用FlashOcx 控件有何不同?
            -- 未解決

            Part 1
            實現一個ActiveX對象的OLE容器需要繼承幾個接口
            IOleClientSite
            IOleInPlaceSiteWindowless
            IOleInPlaceFrame
            IStorage
            (具體做什么,需要找資料惡補一下~~~~ ActiveX, OLE容器……)

            在DEMO里實現了一個OLE容器類叫 COleContainerWnd
            template<CLASS?T>
            class?COleContainerWnd?:?virtual?public?IOleClientSite,
            ?????????????????????????virtual?public?IOleInPlaceSiteWindowless,?
            ?????????????????????????virtual?public?IOleInPlaceFrame,
            ?????????????????????????virtual?public?IStorage

            是個模板類,T是留給 ActiveX?的接口

            Part 2
            把 flash.ocx 引進來,因為里面包含了Flash播放器的相關接口定義,它就是我們要放到容器里的 ActiveX 對象了
            #import?"flash.ocx"?named_guids?

            Part 3
            CFlashWnd派生類
            class?CFlashWnd:?public?COleContainerWnd<ShockwaveFlashObjects::IShockwaveFlash>,
            ???????????????????????????????? public?ShockwaveFlashObjects::_IShockwaveFlashEvents,
            ???????????????????????????????? public?ShockwaveFlashObjects::IServiceProvider
            再汗一下,CFlashWnd 是個容器,還要實現?public ShockwaveFlashObjects::IServiceProvider 接口作甚?

            至于要繼承 ShockwaveFlashObjects::_IShockwaveFlashEvents 接口的目的是為了接收 Flash 動畫發過來的 fscommand()?事件,在 Flash的AS(動作腳本)中調用 FsCommand(),就會
            觸發這個事件了
            (這是一個精通 Flash 的同學告訴我的!!)

            CFlashWnd 對象的創建
            g_flashWnd?=?new?CFlashWnd;
            g_flashWnd->Create(ShockwaveFlashObjects::CLSID_ShockwaveFlash,
            WS_EX_LAYERED,?WS_POPUP?|?WS_VISIBLE?|?WS_CLIPSIBLINGS,
            g_hWnd,?g_hInst);?

            Create() 函數的第一個參數:Flash 播放對象的ClassID
            Create() 函數的第二個參數:窗體的擴展風格 WS_EX_LAYERED ,據說加了這個風格才能實現透明 Flash ,為啥?
            ……

            Part 4
            CFlashWnd::Create() 的內幕
            注冊了窗口類,然后就 CreateWindows? 了

            值得注意的是

            OleCreate() 函數用來創建一個 IOleObject 對象的實例,需要 把 Ole 容器 的?IOleClientSite?和 IStorage?作為參數傳給它
            ????hr?=?OleCreate(m_CLSID,?IID_IOleObject,?OLERENDER_DRAW,
            ????????0,?(IOleClientSite?*)this,?(IStorage?*)this,?(void?**)&m_lpO);

            不解的是,virtual?public?IOleInPlaceSiteWindowless 跟 virtual?public?IOleInPlaceFrame 不用理了?

            ????hr?=?OleSetContainedObject(m_lpO,?TRUE);

            OleSetContainedObject () 函數通知 IOleObject 對象跟它說,你已經被嵌到 OLE 容器里了

            hr?=?m_lpO->QueryInterface(__uuidof(T),?(void?**)&m_lpControl);
            然后用 IOleObject 的 QueryInterface 獲取 IShockwaveFlash 接口(那個 T, 就是 ShockwaveFlashObjects::IShockwaveFlash 了)

            ????hr?=?m_lpO->QueryInterface(IID_IViewObjectEx,?(void?**)&m_lpViewObjectEx);
            同樣的方法,也得到了 IViewObjectEx? 的接口
            IViewObjectEx 用來干嘛的??

            要創建一個無窗口的控件,OLE容器需要? IOleInPlaceObjectWindowless 接口來分派消息給對象, 因為 對象本身沒有自己所屬的窗體
            另外,IOleInPlaceObject 接口需要重出那個對象

            hr?=?m_lpO->DoVerb(OLEIVERB_SHOW,?NULL,?(IOleClientSite?*)this,?0,?NULL,?NULL);
            IOleObject::DoVerb() 用來顯示對象和將對象置為運行的狀態

            這樣,Flash 播放對象就建好了.....

            Part 5.
            透明窗體的重畫

            1、創建窗體時加上 WS_EX_LAYERED 屬性
            2、用 CreateDIBSection() 創建一個 32位的DIB塊, 然后把它 Select 到 DC 里面, It will be an offscreen plain to render window contents to. (這句不知如何譯....)
            3、描繪窗體的內容, preserving the alpha channel. (同上..)
            4、調用 UpdateLayeredWindow() 函數重畫窗體

            描繪 Flash 播放的內容,用 OleDraw() 函數, 在 IViewObject::Draw()? 中調用
            hr?=?OleDraw(lpV,?DVASPECT_TRANSPARENT,?hdcDraw,?&rTotal);?

            lpV?–?IViewObject?
            interface?of?flash?player?control?
            hdcDraw?–?offscreen?plain?
            rTotal?–?client?rectangle?of?the?container?window?

            DVASPECT_TRANSPARENT drawing aspect tells the object to draw it's content using alpha blending.

            DVASPECT_TRANSPARENT drawing aspect tells the object to draw it's content using alpha blending.

            While implementing this, I have met a serious bug in Flash Player Control 8. This bug is only in this version. Players 7 and 9 are free of it. The bug is in the way Flash Control fills the alpha channel of a 32 bit device context. If at least 1 of 255 alpha values is applied to pixel, the colors are mixed correctly, but the resulting alpha channel is set to 255, even if it was initially zero. This makes it impossible to create semitransparent windows. So I had to develop a solution to fix this bug. The solution is quite simple:

            These equations are used by Flash Player Control for alpha blending:

            R' = Rdst * (1 – alpha) + Rsrc * alpha
            G' = Gdst * (1 – alpha) + Gsrc * alpha
            B' = Bdst * (1 – alpha) + Bsrc * alpha

            If I draw the contents of Flash onto black surface I get

            R'black = Rsrc * alpha
            G'black = Gsrc * alpha
            B'black = Bsrc * alpha

            If I draw the contents of Flash onto white surface I get

            R'white = 255 * (1 – alpha) + Rsrc * alpha
            G'white = 255 * (1 – alpha) + Rsrc * alpha
            B'white = 255 * (1 – alpha) + Rsrc * alpha

            Here is the system of equations:

            R'black = Rsrc * alpha
            R'white = 255 * (1 – alpha) + Rsrc * alpha

            where alpha and Rsrc are unknown. After solving it you will get:

            (255-Alpha) = R'white – R'black

            Alpha = 255 – (R'white – R'black)

            So, the solution is found. Now, we can draw contents of flash player twice and then correct the corrupted alpha channel.

            Part 6. Events
            Flash Player 對象的事件是用IDispatch來處理的,在創建后得到一個 IConnectionPointContainer 去獲取 DIID__IShockwaveFlashEvents 的 連接點(connection point)
            hr?=?m_lpControl->QueryInterface(IID_IConnectionPointContainer,
            (
            void**)&m_lpConCont);
            if?(FAILED(hr))
            return?FALSE;
            hr?
            =?m_lpConCont->FindConnectionPoint(
            ShockwaveFlashObjects::DIID__IShockwaveFlashEvents,?
            &m_lpConPoint);
            if?(FAILED(hr))
            return?FALSE;
            hr?
            =?m_lpConPoint->Advise(
            (ShockwaveFlashObjects::_IShockwaveFlashEvents
            *)this,
            &m_dwConPointID);
            if?(FAILED(hr))
            return?FALSE;

            Part 7. DirectDraw
            為了提交重畫的性能,所以使用 DirectDraw 接口
            Flash對象通過 ShockwaveFlashObjects::IServiceProvider::raw_RemoteQueryService 這個接口來訪問它
            (需要找一下 FlashObject 接口的文檔了解一下)


            (眼睛睜不開,需要先睡一會………………)






            亚洲精品无码久久一线| 伊人久久大香线蕉无码麻豆 | 一级做a爰片久久毛片免费陪| 久久精品国产亚洲AV不卡| 国产高清美女一级a毛片久久w | 色欲久久久天天天综合网| 久久精品亚洲福利| 一本一本久久a久久精品综合麻豆| 色婷婷综合久久久久中文一区二区| 青青草原综合久久大伊人导航| 91视频国产91久久久| 久久久亚洲欧洲日产国码aⅴ| 囯产精品久久久久久久久蜜桃| 亚洲色欲久久久久综合网| 久久久久香蕉视频| AV色综合久久天堂AV色综合在| 久久国产乱子伦免费精品| 久久久久亚洲av无码专区导航 | 久久亚洲熟女cc98cm| 亚洲国产精品无码久久久久久曰| 久久久久久久久久久免费精品| 国产—久久香蕉国产线看观看| 91久久精品无码一区二区毛片| 久久亚洲精品中文字幕三区| 久久本道伊人久久| 国产成人久久精品一区二区三区| 精品蜜臀久久久久99网站| 97精品国产91久久久久久| 久久最近最新中文字幕大全| 国产精品欧美久久久久无广告| 久久激情亚洲精品无码?V| 欧美大战日韩91综合一区婷婷久久青草 | 91久久九九无码成人网站| 国产一区二区精品久久凹凸| 国产精品日韩深夜福利久久| 久久久久国产亚洲AV麻豆| 久久se精品一区精品二区国产| 色欲av伊人久久大香线蕉影院| 国产成人精品久久免费动漫| 91精品国产高清久久久久久91| 午夜精品久久久久久久|