bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool) { if (!m_image) return false; NativeImagePtr nativeImage = m_image->nativeImageForCurrentFrame(); if (!nativeImage) return false; m_imageWidth = nativeImage->width(); m_imageHeight = nativeImage->height(); if (!m_imageWidth || !m_imageHeight) return false; unsigned imageSize = m_imageWidth * m_imageHeight; m_imageData.resize(imageSize); if (!nativeImage->readPixels(m_imageData.data(), imageSize)) return false; // Raw image data is premultiplied m_alphaOp = AlphaDoNothing; if (!premultiplyAlpha) m_alphaOp = AlphaDoUnmultiply; m_imagePixelData = m_imageData.data(); m_imageSourceFormat = DataFormatBGRA8; m_imageSourceUnpackAlignment = 0; return true; }
static void loadBufferingImageData() { static bool loaded = false; if (!loaded) { static Image* bufferingIcon = Image::loadPlatformResource("vidbuffer").leakRef(); NativeImagePtr nativeImage = bufferingIcon->nativeImageForCurrentFrame(); if (!nativeImage) return; loaded = true; s_bufferingImageWidth = bufferingIcon->width(); s_bufferingImageHeight = bufferingIcon->height(); int bufSize = bufferingIcon->decodedSize(); s_bufferingImageData = static_cast<unsigned*>(malloc(bufSize)); nativeImage->readPixels(s_bufferingImageData, s_bufferingImageWidth * s_bufferingImageHeight); bufferingIcon->deref(); } }