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

📄 pxpngrnd.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                if (m_pDecode->GetValid())                {                    IHXBuffer* pBuffer = pPacket->GetBuffer();                    if (pBuffer)                    {                        if (!m_ulPacketIndex)                        {                            // This is the first packet, so we need to first Init()                            retVal = m_pDecode->Init(m_pContext,                                                     pBuffer,                                                     TRUE);                            if (SUCCEEDED(retVal))                            {                                // Get the image store from the PXImage                                IHXBuffer* pImageStore = NULL;                                retVal = m_pImage->GetImageStore(&pImageStore);                                if (SUCCEEDED(retVal))                                {                                    // Set the decompress params                                    retVal = m_pDecode->SetDecompressParam(pImageStore,                                                                           (UINT32) m_pImage->GetWidth(),                                                                           (UINT32) m_pImage->GetHeight(),                                                                           (UINT32) m_pImage->GetRowStride(),                                                                           m_pImage->GetBitsPerPixel(),                                                                           m_pImage->GetFormat(),                                                                           m_pImage->GetRowsInverted());                                }                                HX_RELEASE(pImageStore);                            }                        }                        if (SUCCEEDED(retVal))                        {                            // Process the packet                            retVal = m_pDecode->Decompress(pBuffer);                            if (SUCCEEDED(retVal))                            {                                // Increment the packet index                                m_ulPacketIndex++;                                // If we're done, then we can delete the decompress object                                if (m_pDecode->IsFinished())                                {                                    // Set the flag that says whether or not                                    // the raw image uses an alpha channel.                                    // Depending upon the externally applied                                    // transparency parameters, this could be different                                    // from the flag that says whether or not the                                    // display buffer uses the alpha channel.                                    m_bImageUsesAlphaChannel = m_pDecode->UsesAlphaChannel();                                    // Release the decompress object                                    HX_RELEASE(m_pDecode);                                    // Initially update the display buffer                                    retVal = UpdateDisplayBuffer();                                    if (SUCCEEDED(retVal))                                    {                                        // Set the flag                                        m_bDecodeFinished = TRUE;                                    }                                }                            }                            else                            {                                // Clear the valid flag                                m_pDecode->SetValid(FALSE);                                // Reset the error return - we don't want GetPacket to report failure                                retVal = HXR_OK;                            }                        }                    }                    else                    {                        retVal = HXR_FAIL;                    }                    HX_RELEASE(pBuffer);                }            }        }        else        {            retVal = HXR_UNEXPECTED;        }    }    else    {        retVal = HXR_INVALID_PARAMETER;    }    return retVal;}STDMETHODIMP PXPNGRenderer::OnTimeSyncOffset(UINT32 ulTime){#ifdef XXXMEH_DEBUG_LOG    DEBUG_OUTF("c:\\png.log",               (s, "0x%08x::OnTimeSyncOffset(%lu)\n", this, ulTime));#endif    // We should force a redraw ONLY on the first time sync after the image    // has finished decoding    if (m_bDecodeFinished && m_bFirstDraw)    {        // Redraw our data by damaging the entire area of our data        HXxSize size;        m_pSite->GetSize(size);        HXxRect damageRect = {0, 0, size.cx, size.cy};        m_pSite->DamageRect(damageRect);        m_pSite->ForceRedraw();        // Clear the first draw flag        m_bFirstDraw = FALSE;    }    return HXR_OK;}STDMETHODIMP PXPNGRenderer::GetWindowSize(REF(HXxSize) rSize){    rSize.cx = m_ulImageWidth;    rSize.cy = m_ulImageHeight;    return HXR_OK;}STDMETHODIMP PXPNGRenderer::IsMouseOverActiveLink(INT16 x, INT16 y, REF(BOOL) rbActive, REF(IHXBuffer*) rpLink){    HX_RESULT retVal = HXR_OK;    // By default we are NOT over a link    rbActive = FALSE;    // Make sure mouse is in the window    if (x >= 0 && x < (INT16) m_ulImageWidth &&        y >= 0 && y < (INT16) m_ulImageHeight)    {        // Make sure a URL string exists        if (m_pURLStr)        {            rbActive = TRUE;            HX_RELEASE(rpLink);            rpLink = m_pURLStr;            rpLink->AddRef();        }    }    return retVal;}STDMETHODIMP PXPNGRenderer::RMASurfaceUpdate(IHXVideoSurface* pSurface){#ifdef XXXMEH_DEBUG_LOG    DEBUG_OUTF("c:\\png.log", (s, "RMASurfaceUpdate(0x%08X,0x%08X)\n", this, pSurface));#endif    if (pSurface && m_pSite && m_pDisplayImage && m_bDecodeFinished)    {        // Get the size of the site        HXxSize size;        m_pSite->GetSize(size);        // Set up the dst rect        HXxRect rDestRect = { 0, 0, size.cx, size.cy};        // Set up the src rect        HXxRect rSrcRect  = { 0,                              0,                              m_pDisplayImage->GetWidth(),                              m_pDisplayImage->GetHeight() };        // Set the values in the bitmap info header        HXBitmapInfoHeader cHeader;        cHeader.biSize          = 40;        cHeader.biWidth         = m_pDisplayImage->GetWidth();        cHeader.biHeight        = m_pDisplayImage->GetHeight();        cHeader.biPlanes        = 1;        cHeader.biBitCount      = 32;        cHeader.biCompression   = (m_bDisplayUsesAlphaChannel ? HX_ARGB : HX_RGB);        cHeader.biSizeImage     = 0;        cHeader.biXPelsPerMeter = 0;        cHeader.biYPelsPerMeter = 0;        cHeader.biClrUsed       = 0;        cHeader.biClrImportant  = 0;        cHeader.rcolor          = 0;        cHeader.gcolor          = 0;        cHeader.bcolor          = 0;        // Get the image store        IHXBuffer* pBuffer = NULL;        m_pDisplayImage->GetImageStore(&pBuffer);        if (pBuffer)        {//            char szDbgStr[128];//            DEBUGPRINTF(szDbgStr, "0x%08x PXPNGRenderer Blts alpha=%lu tick=%lu\n",//                        this, m_bDisplayUsesAlphaChannel, HX_GET_BETTERTICKCOUNT());            // Blit to the video surface            pSurface->Blt(pBuffer->GetBuffer(),                          &cHeader,                          rDestRect,                          rSrcRect);        }        HX_RELEASE(pBuffer);    }    return HXR_OK;}HX_RESULT PXPNGRenderer::RMASurfaceUpdate2(IHXSubRectVideoSurface* pSurface,                                           HXxRect*                 pExtents,                                           HXxBoxRegion*              pDirtyRegion ){    if (pSurface && m_pSite && m_pDisplayImage && m_bDecodeFinished)    {        // Get the size of the site        HXxSize size;        m_pSite->GetSize(size);                //Scale dirty rects.        float fx = (float)m_pDisplayImage->GetWidth()/(float)size.cx;        float fy = (float)m_pDisplayImage->GetHeight()/(float)size.cy;        //Go through each rect in the dirty region and scale it to         //generate the src rects.        HXBOX* pSrcRects = new HXBOX[pDirtyRegion->numRects];        for( int i=0 ; i<pDirtyRegion->numRects; i++ )        {            pSrcRects[i].x1 = (float)pDirtyRegion->rects[i].x1*fx+.5;            pSrcRects[i].x2 = (float)pDirtyRegion->rects[i].x2*fx+.5;            pSrcRects[i].y1 = (float)pDirtyRegion->rects[i].y1*fy+.5;            pSrcRects[i].y2 = (float)pDirtyRegion->rects[i].y2*fy+.5;        }        //Set up Src region.        HXxBoxRegion srcRegion;        srcRegion.numRects = pDirtyRegion->numRects;        srcRegion.rects    = pSrcRects;                // Set the values in the bitmap info header        HXBitmapInfoHeader cHeader;        cHeader.biSize          = 40;        cHeader.biWidth         = m_pDisplayImage->GetWidth();        cHeader.biHeight        = m_pDisplayImage->GetHeight();        cHeader.biPlanes        = 1;        cHeader.biBitCount      = 32;        cHeader.biCompression   = (m_bDisplayUsesAlphaChannel ? HX_ARGB : HX_RGB);        cHeader.biSizeImage     = 0;        cHeader.biXPelsPerMeter = 0;        cHeader.biYPelsPerMeter = 0;        cHeader.biClrUsed       = 0;        cHeader.biClrImportant  = 0;        cHeader.rcolor          = 0;        cHeader.gcolor          = 0;        cHeader.bcolor          = 0;                // Get the image store        IHXBuffer* pBuffer = NULL;        m_pDisplayImage->GetImageStore(&pBuffer);        if (pBuffer)        {            // Blit to the video surface            pSurface->BltSubRects(pBuffer->GetBuffer(),                                  &cHeader,                                  pDirtyRegion,                                  &srcRegion, 1.0/fx, 1.0/fy);        }        HX_RELEASE(pBuffer);        HX_VECTOR_DELETE( pSrcRects );    }    return HXR_OK;}STDMETHODIMP PXPNGRenderer::HandleClick(INT16 x, INT16 y){    if (m_pHyperNavigate && m_pURLStr)    {        const char* pszURL    = (const char*) m_pURLStr->GetBuffer();        if (strlen(pszURL) > 0)        {            const char* pszTarget = (strstr(pszURL, "command:") ? "_player" : NULL);            m_pHyperNavigate->GoToURL(pszURL, pszTarget);        }    }    return HXR_OK;}STDMETHODIMP PXPNGRenderer::SetPropertyULONG32(const char* pName, ULONG32 ulVal){    HX_RESULT retVal = HXR_OK;    if (pName)    {        // Check to see if this is a property we're interested        // in monitoring        BOOL bUpdateNeeded = FALSE;        if (!strcmp(pName, "backgroundOpacity"))        {            if (ulVal > 255) ulVal = 255;            if (ulVal != m_ulBackgroundOpacity)            {                bUpdateNeeded = TRUE;                // Update the background color                UINT32 ulAlpha = 255 - ulVal;                m_ulBackgroundColor = (m_ulBackgroundColor & 0x00FFFFFF) |                                      (ulAlpha << 24);            }            m_ulBackgroundOpacity = ulVal;        }        else if (!strcmp(pName, "mediaOpacity"))        {            if (ulVal > 255) ulVal = 255;            if (ulVal != m_ulMediaOpacity) bUpdateNeeded = TRUE;            m_ulMediaOpacity = ulVal;        }        else if (!strcmp(pName, "chromaKey"))

⌨️ 快捷键说明

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