NativeImagePtr ImageSource::createFrameAtIndex(size_t index) { if (!m_decoder) return 0; RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) return 0; return buffer->asNewNativeImage(); }
NativeImagePtr ImageSource::createFrameAtIndex(size_t index) { if (!m_decoder) return 0; // Note that the buffer can have NULL bytes even when it is marked as // non-empty. It seems "FrameEmpty" is only set before the frame has been // initialized. If it is decoded and it happens to be empty, it will be // marked as "FrameComplete" but will still have NULL bytes. RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) return 0; // Copy the bitmap. The pixel data is refcounted internally by SkBitmap, so // this doesn't cost much. return buffer->asNewNativeImage(); }
NativeImagePtr ImageSource::createFrameAtIndex(size_t index) { if (!initialized()) return 0; if (!m_decoder) return 0; RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index); if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty) return 0; // Cairo does not like zero height images. // If we have a zero height image, just pretend we don't have enough data yet. if (!size().height()) return 0; return buffer->asNewNativeImage(); }