📄 pxpngrnd.cpp
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: pxpngrnd.cpp,v 1.4.22.1 2004/07/09 01:52:28 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 "hxtypes.h"#include "hxwintyp.h"#include "hxcom.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxcore.h"#include "hxrendr.h"#include "hxhyper.h"#include "hxplugn.h"#include "hxwin.h"#include "hxasm.h"#include "hxevent.h"#include "hxvsurf.h"#include "hxver.h"#include "hxupgrd.h"#include "hxengin.h"#include "hxmon.h"#include "hxprefs.h"#include "hxerror.h"// pncont#include "hxbuffer.h"#include "hxstring.h"// pnmisc#include "unkimp.h"#include "baseobj.h"#include "hxtick.h"// baserend#include "baserend.h"#include "vbasernd.h"// pndebug#include "debugout.h"#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILE static char HX_THIS_FILE[] = __FILE__;#endif#include "errdbg.h"// pxcomlib#include "glist.h"#include "gstring.h"#include "pxutil.h"#include "pxcolor.h"#include "parseurl.h"#include "pxrect.h"#include "pximage.h"#include "pxtransp.h"// libpng#include "png.h"// pxpnglib#include "pxpngdec.h"// pxpngrnd#include "pngrmlog.h"#include "pxpngrnd.h"#include "pngrdll.ver"#ifdef _AIX#include "dllpath.h"ENABLE_MULTILOAD_DLLACCESS_PATHS(Pxpngrnd);#endif// Define whether we're row inverted or not#if defined(_WINDOWS)#define ROWS_INVERTED TRUE#else#define ROWS_INVERTED FALSE#endifconst char* const PXPNGRenderer::m_pszName = "PNG";const char* const PXPNGRenderer::m_pszDescription = "Helix PNG Renderer Plugin";const char* const PXPNGRenderer::m_ppszMimeType[] = {"application/vnd.rn-pngstream", NULL};PXPNGRenderer::PXPNGRenderer() : CRNVisualBaseRenderer(){ MLOG_LEAK("CON PXPNGRenderer this=0x%08x\n", this); m_ulImageWidth = 0; m_ulImageHeight = 0; m_ulNumPackets = 0; m_ulBackgroundColor = 0x00000000; m_pURLStr = NULL; m_pImage = NULL; m_pDisplayImage = NULL; m_pDecode = NULL; m_ulPacketIndex = 0; m_bFirstDraw = TRUE; m_bDecodeFinished = FALSE; m_ulBackgroundOpacity = 255; m_ulMediaOpacity = 255; m_ulMediaChromaKey = 0; m_bMediaChromaKeySpecified = FALSE; m_ulMediaChromaKeyTolerance = 0; m_ulMediaChromaKeyOpacity = 0; m_bImageUsesAlphaChannel = FALSE; m_bDisplayUsesAlphaChannel = FALSE;};PXPNGRenderer::~PXPNGRenderer(){ MLOG_LEAK("DES PXPNGRenderer this=0x%08x\n", this); HX_RELEASE(m_pURLStr); HX_RELEASE(m_pImage); HX_RELEASE(m_pDisplayImage); HX_RELEASE(m_pDecode);};STDMETHODIMP PXPNGRenderer::QueryInterface(REFIID riid, void** ppvObj){ return CRNVisualBaseRenderer::QueryInterface(riid, ppvObj);}STDMETHODIMP_(UINT32) PXPNGRenderer::AddRef(){ return CRNVisualBaseRenderer::AddRef();}STDMETHODIMP_(UINT32) PXPNGRenderer::Release(){ return CRNVisualBaseRenderer::Release();}STDMETHODIMP PXPNGRenderer::OnHeader(IHXValues* pHeader){#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\png.log", (s, "OnHeader(0x%08X)\n", this));#endif HX_RESULT retVal = HXR_FAIL; if (pHeader) { // Check presentation stream and content versions retVal = CheckStreamVersions(pHeader); if (SUCCEEDED(retVal)) { // Get the opaque data from the stream header IHXBuffer* pOpaque = NULL; retVal = pHeader->GetPropertyBuffer("OpaqueData", pOpaque); if (SUCCEEDED(retVal)) { // Unpack the stream header BYTE* pBuf = pOpaque->GetBuffer(); UnPack32(pBuf, m_ulImageWidth); UnPack32(pBuf, m_ulImageHeight); UnPack32(pBuf, m_ulNumPackets); UnPack32(pBuf, m_ulBackgroundColor); UINT16 usURLSize = 0; UnPack16(pBuf, usURLSize); if (usURLSize) { HX_RELEASE(m_pURLStr); retVal = m_pCommonClassFactory->CreateInstance(CLSID_IHXBuffer, (void**) &m_pURLStr); if (SUCCEEDED(retVal)) { retVal = m_pURLStr->Set((const BYTE*) pBuf, (UINT32) usURLSize); } } if (SUCCEEDED(retVal)) { // Create the raw decoded image HX_RELEASE(m_pImage); retVal = PXImage::CreateObject(&m_pImage); if (SUCCEEDED(retVal)) { // AddRef the object m_pImage->AddRef(); // Init the image retVal = m_pImage->Create((INT32) m_ulImageWidth, // width (INT32) m_ulImageHeight, // height 32, // bpp HX_RGB, // color format ROWS_INVERTED, // row inversion TRUE); // always allocate if (SUCCEEDED(retVal)) { // Fill it initially with the background color m_pImage->Fill32(m_ulBackgroundColor); // Create the display image HX_RELEASE(m_pDisplayImage); retVal = PXImage::CreateObject(&m_pDisplayImage); if (SUCCEEDED(retVal)) { // AddRef the object m_pDisplayImage->AddRef(); // Init the display image retVal = m_pDisplayImage->Create((INT32) m_ulImageWidth, // width (INT32) m_ulImageHeight, // height 32, // bpp HX_RGB, // color format ROWS_INVERTED, // row inversion TRUE); // always allocate if (SUCCEEDED(retVal)) { // Fill it initially with the background color m_pDisplayImage->Fill32(m_ulBackgroundColor); // Add the alpha channel to the background color UINT32 ulAlpha = 255 - m_ulBackgroundOpacity; m_ulBackgroundColor = (m_ulBackgroundColor & 0x00FFFFFF) | (ulAlpha << 24); // Create the PNG decode object HX_RELEASE(m_pDecode); m_pDecode = new PXPNGDecode(); if (m_pDecode) { // AddRef the object m_pDecode->AddRef(); // Init the packet index m_ulPacketIndex = 0; } else { retVal = HXR_OUTOFMEMORY; } } } } } } } HX_RELEASE(pOpaque); } else { AddMimeToUpgradeCollection(m_ppszMimeType[0]); } } return retVal;}STDMETHODIMP PXPNGRenderer::OnPacketNoOffset(IHXPacket* pPacket){#ifdef XXXMEH_DEBUG_LOG DEBUG_OUTF("c:\\png.log", (s, "OnPacketNoOffset(0x%08X)\n", this));#endif HX_RESULT retVal = HXR_OK; if (pPacket) { if (m_pImage && m_pDecode) { if (!pPacket->IsLost()) { // If the valid flag is TRUE, life is good. However, if valid is // FALSE, then we've lost a packet and we cannot recover, so // don't even try it.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -