⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pxpngff.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: pxpngff.cpp,v 1.3.24.1 2004/07/09 01:52:41 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */// include#include "hxcom.h"#include "hxtypes.h"#include "hxwintyp.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxformt.h"#include "hxplugn.h"#include "hxpends.h"#include "hxasm.h"#include "hxerror.h"#include "hxver.h"#include "hxxres.h"#include "hxxrsmg.h"#include "ihxfgbuf.h"// pncont#include "chxpckts.h"#include "hxstring.h"#include "chxfgbuf.h"// pnmisc#include "hxurl.h"#include "unkimp.h"#include "baseobj.h"#include "hxparse.h"#ifdef _AIX#include "dllpath.h"ENABLE_MULTILOAD_DLLACCESS_PATHS(Pxpngff);#endif// pxcomlib#include "gstring.h"#include "pxcolor.h"#include "parseurl.h"#include "pxutil.h"#include "nestbuff.h"// libpng#include "png.h"// pxpnglib#include "pxpngdec.h"// coreres#include "pixres.h"// pxpngff#include "pxpngff.h"#include "pngfdll.ver"// pndebug#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE             static char HX_THIS_FILE[] = __FILE__;#endif#include "errdbg.h"const char* const  PXPNGFileFormat::m_pszDescription       = "Helix PNG File Format Plugin";const char* const  PXPNGFileFormat::m_pszCopyright         = HXVER_COPYRIGHT;const char* const  PXPNGFileFormat::m_pszMoreInfoURL       = HXVER_MOREINFO;const char* const  PXPNGFileFormat::m_ppszFileMimeTypes[]  = {"image/png", NULL};const char* const  PXPNGFileFormat::m_ppszFileExtensions[] = {"png", NULL};const char* const  PXPNGFileFormat::m_ppszFileOpenNames[]  = {"PNG Images (*.png)", NULL};const char* const  PXPNGFileFormat::m_pszStreamMimeType    = "application/vnd.rn-pngstream";const UINT32 PXPNGFileFormat::m_ulContentVersion     = HX_ENCODE_PROD_VERSION(0, 0, 0, 0);const UINT32 PXPNGFileFormat::m_ulStreamVersion      = HX_ENCODE_PROD_VERSION(0, 0, 0, 0);#ifdef _WINDOWSextern HINSTANCE g_hInstance;#endifPXPNGFileFormat::PXPNGFileFormat(){    m_lRefCount = 0;    Reset();};PXPNGFileFormat::~PXPNGFileFormat(){    Deallocate();};STDMETHODIMP PXPNGFileFormat::QueryInterface(REFIID riid, void** ppvObj){    HX_RESULT retVal = HXR_OK;    if (IsEqualIID(riid, IID_IUnknown))    {        AddRef();        *ppvObj = (IUnknown*) (IHXPlugin*) this;    }    else if (IsEqualIID(riid, IID_IHXPlugin))    {        AddRef();        *ppvObj = (IHXPlugin*) this;    }    else if (IsEqualIID(riid, IID_IHXFileFormatObject))    {        AddRef();        *ppvObj = (IHXFileFormatObject*) this;    }    else if (IsEqualIID(riid, IID_IHXFileResponse))    {        AddRef();        *ppvObj = (IHXFileResponse*) this;    }    else    {        *ppvObj = NULL;        retVal  = HXR_NOINTERFACE;    }    return retVal;}STDMETHODIMP_(UINT32) PXPNGFileFormat::AddRef(){    return InterlockedIncrement(&m_lRefCount);}STDMETHODIMP_(UINT32) PXPNGFileFormat::Release(){    if (InterlockedDecrement(&m_lRefCount) > 0)    {        return m_lRefCount;    }    delete this;    return 0;}STDMETHODIMP PXPNGFileFormat::GetPluginInfo(REF(BOOL)        rbLoadMultiple,                                            REF(const char*) rpszDescription,                                            REF(const char*) rpszCopyright,                                            REF(const char*) rpszMoreInfoURL,                                            REF(UINT32)      rulVersionNumber){    rbLoadMultiple   = TRUE;    rpszDescription  = m_pszDescription;    rpszCopyright    = m_pszCopyright;    rpszMoreInfoURL  = m_pszMoreInfoURL;    rulVersionNumber = TARVER_ULONG32_VERSION;    return HXR_OK;}STDMETHODIMP PXPNGFileFormat::InitPlugin(IUnknown* pContext){    HX_RESULT retVal = HXR_FAIL;    if (pContext)    {        // Clear out everything        Deallocate();        // Save a copy of the calling context        m_pContext = pContext;        m_pContext->AddRef();        // Get an interface to the common class factory        retVal = m_pContext->QueryInterface(IID_IHXCommonClassFactory,                                            (void**) &m_pCommonClassFactory);        if (SUCCEEDED(retVal))        {            // Set the state            m_ulState = kStatePluginInitialized;        }    }    return retVal;}STDMETHODIMP PXPNGFileFormat::GetFileFormatInfo(REF(const char**) rppszFileMimeTypes,                                                REF(const char**) rppszFileExtensions,                                                  REF(const char**) rppszFileOpenNames){    rppszFileMimeTypes  = (const char **) m_ppszFileMimeTypes;    rppszFileExtensions = (const char **) m_ppszFileExtensions;    rppszFileOpenNames  = (const char **) m_ppszFileOpenNames;    return HXR_OK;}STDMETHODIMP PXPNGFileFormat::InitFileFormat(IHXRequest*        pRequest,                                              IHXFormatResponse* pFormatResponse,                                             IHXFileObject*     pFileObject){    HX_RESULT retVal = HXR_FAIL;    if (pRequest && pFormatResponse && pFileObject)    {        if (m_ulState == kStatePluginInitialized)        {            // Save members            HX_RELEASE(m_pRequest);            m_pRequest = pRequest;            m_pRequest->AddRef();            HX_RELEASE(m_pFormatResponse);            m_pFormatResponse = pFormatResponse;            m_pFormatResponse->AddRef();            HX_RELEASE(m_pFileObject);            m_pFileObject = pFileObject;            m_pFileObject->AddRef();            // Get the URL-encoded options            GetURLOrRequestOptions(pRequest,                                   m_ulDuration,                                   m_ulBitrate,                                   m_pURLStr,                                   m_bReliable,                                   m_ulBackgroundColor);            // Set the state            m_ulState = kStateFileInitPending;            // Init the file object            retVal = m_pFileObject->Init(HX_FILE_READ | HX_FILE_BINARY, this);        }    }    if (FAILED(retVal) && pFormatResponse)    {        pFormatResponse->InitDone(HXR_FAIL);    }    return retVal;}STDMETHODIMP PXPNGFileFormat::GetFileHeader(){    HX_RESULT retVal = HXR_OK;    if (m_ulState == kStateFileFormatInitialized)    {        // Get an IHXValues object        IHXValues* pFileHeader = NULL;        retVal                  = m_pCommonClassFactory->CreateInstance(CLSID_IHXValues,                                                                        (void**) &pFileHeader);        if (SUCCEEDED(retVal))        {            // Set the stream count            pFileHeader->SetPropertyULONG32("StreamCount",    1);            pFileHeader->SetPropertyULONG32("IsRealDataType", 1);            // Set the width and height            pFileHeader->SetPropertyULONG32("Width",  m_ulImageWidth);            pFileHeader->SetPropertyULONG32("Height", m_ulImageHeight);            // Set the new state            m_ulState = kStateFileHeaderSent;            // Call the response interface            m_pFormatResponse->FileHeaderReady(HXR_OK, pFileHeader);        }        HX_RELEASE(pFileHeader);        if (FAILED(retVal))        {            m_pFormatResponse->FileHeaderReady(retVal, NULL);        }    }    else    {        retVal = HXR_UNEXPECTED;    }    return retVal;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -