Index: Source/platform/graphics/ImageBuffer.cpp |
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp |
index f37ac2bb71c84c90e8fe4aedfefdaf731fbd53b4..fbba10befe101257b532e3a883d45f7acc67d72f 100644 |
--- a/Source/platform/graphics/ImageBuffer.cpp |
+++ b/Source/platform/graphics/ImageBuffer.cpp |
@@ -396,7 +396,10 @@ static bool encodeImage(T& source, const String& mimeType, const double* quality |
if (!WEBPImageEncoder::encode(source, compressionQuality, encodedImage)) |
return false; |
} else { |
- if (!PNGImageEncoder::encode(source, encodedImage)) |
+ int compressionQuality = PNGImageEncoder::DefaultCompressionQuality; |
+ if (quality && *quality >= 0.0 && *quality <= 1.0) |
+ compressionQuality = static_cast<int>(*quality * 100 + 0.5); |
+ if (!PNGImageEncoder::encode(source, compressionQuality, encodedImage)) |
return false; |
ASSERT(mimeType == "image/png"); |
} |
@@ -411,6 +414,7 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con |
Vector<char> encodedImage; |
if (!isSurfaceValid() || !encodeImage(m_surface->bitmap(), mimeType, quality, &encodedImage)) |
return "data:,"; |
+ |
Vector<char> base64Data; |
base64Encode(encodedImage, base64Data); |