コード例 #1
0
String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
{
    SkDevice* device = context()->platformContext()->canvas()->getDevice();
    SkBitmap bitmap = device->accessBitmap(false);

    // if we can't see the pixels directly, call readPixels() to get a copy.
    // this could happen if the device is backed by a GPU.
    bitmap.lockPixels(); // balanced by our destructor, or explicitly if getPixels() fails
    if (!bitmap.getPixels()) {
        bitmap.unlockPixels();
        SkIRect bounds = SkIRect::MakeWH(device->width(), device->height());
        if (!device->readPixels(bounds, &bitmap))
            return "data:,";
    }

    return ImageToDataURL(bitmap, mimeType, quality);
}
コード例 #2
0
String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
{
    ASSERT(context() && context()->platformContext());

    // Request for canvas bitmap; conversion required.
    if (context()->platformContext()->isRecording())
        context()->platformContext()->convertToNonRecording();
// CAPPFIX_WEB_WEBGL
     SkCanvas* canvas = imageBufferCanvas(this);
// CAPPFIX_WEB_WEBGL_END
     SkDevice* device = canvas->getDevice();
     SkBitmap bitmap = device->accessBitmap(false);
     // if we can't see the pixels directly, call readPixels() to get a copy.
     // this could happen if the device is backed by a GPU.
     bitmap.lockPixels(); // balanced by our destructor, or explicitly if getPixels() fails
     if (!bitmap.getPixels()) {
         bitmap.unlockPixels();
         SkIRect bounds = SkIRect::MakeWH(device->width(), device->height());
         if (!canvas->readPixels(bounds, &bitmap))
             return "data:,";
     }

     return ImageToDataURL(bitmap, mimeType, quality);
}
コード例 #3
0
String ImageDataToDataURL(const ImageData& source, const String& mimeType, const double* quality)
{
    return ImageToDataURL(source, mimeType, quality);
}
コード例 #4
0
ファイル: ImageBufferSkia.cpp プロジェクト: Xertz/EAWebKit
String ImageBuffer::toDataURL(const String& mimeType, const double* quality) const
{
    m_context->platformContext()->makeGrContextCurrent();
    SkDevice* device = context()->platformContext()->canvas()->getDevice();
    return ImageToDataURL(device->accessBitmap(false), mimeType, quality);
}