예제 #1
0
        public override void ContentArrived(byte[] data, MHEngine engine)
        {
            Region updateArea = GetVisibleArea(); // If there's any content already we have to redraw it.

            if (m_pContent == null)
            {
                return;                     // Shouldn't happen.
            }
            int nCHook = m_nContentHook;

            if (nCHook == 0)
            {
                nCHook = engine.GetDefaultBitmapCHook();
            }

            // TODO: What if we can't convert it?
            if (nCHook == 4)
            { // PNG.
                m_pContent.CreateFromPNG(data);
            }
            else if (nCHook == 2)
            { // MPEG I-frame.
                m_pContent.CreateFromMPEG(data);
            }
            else
            {
                throw new MHEGException("Unknown bitmap content hook " + nCHook);
            }

            updateArea.Union(GetVisibleArea()); // Redraw this bitmap.
            engine.Redraw(updateArea);          // Mark for redrawing

            // Now signal that the content is available.
            engine.EventTriggered(this, EventContentAvailable);
        }