Changeset 36508 in webkit
- Timestamp:
- Sep 16, 2008 9:59:18 AM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r36506 r36508 1 2008-09-16 Dirk Schulze <vbs85@gmx.de> 2 3 Reviewed by Oliver Hunt and Alp Toker. 4 5 Implemented toDataURL in Cairo. Only PNG support 6 at the moment. 7 8 Qt, Cairo and wx require toDataURL implementations 9 https://bugs.webkit.org/show_bug.cgi?id=17719 10 11 * platform/MIMETypeRegistry.cpp: 12 (WebCore::initializeSupportedImageMIMETypesForEncoding): 13 * platform/graphics/cairo/ImageBufferCairo.cpp: 14 (WebCore::ImageBuffer::ImageBuffer): 15 (WebCore::writeFunction): 16 (WebCore::ImageBuffer::toDataURL): 17 1 18 2008-09-16 Tor Arne Vestbø <tavestbo@trolltech.com> 2 19 -
trunk/WebCore/platform/MIMETypeRegistry.cpp
r36269 r36508 148 148 supportedImageMIMETypesForEncoding->add(mimeType); 149 149 } 150 #elif PLATFORM(CAIRO) 151 supportedImageMIMETypesForEncoding->add("image/png"); 150 152 #endif 151 153 } -
trunk/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r35747 r36508 28 28 #include "ImageBuffer.h" 29 29 30 #include "Base64.h" 30 31 #include "BitmapImage.h" 31 32 #include "GraphicsContext.h" 32 33 #include "ImageData.h" 34 #include "MIMETypeRegistry.h" 33 35 #include "NotImplemented.h" 34 36 #include "Pattern.h" 37 #include "PlatformString.h" 35 38 36 39 #include <cairo.h> 40 #include <wtf/Vector.h> 37 41 38 42 using namespace std; … … 50 54 } 51 55 52 ImageBuffer::ImageBuffer( _cairo_surface* surface)56 ImageBuffer::ImageBuffer(cairo_surface_t* surface) 53 57 : m_surface(surface) 54 58 { … … 95 99 } 96 100 97 String ImageBuffer::toDataURL(const String&) const 101 static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned int length) 98 102 { 99 notImplemented(); 100 return String(); 103 Vector<char>* in = reinterpret_cast<Vector<char>*>(closure); 104 in->append(data, length); 105 return CAIRO_STATUS_SUCCESS; 106 } 107 108 String ImageBuffer::toDataURL(const String& mimeType) const 109 { 110 cairo_surface_t* image = cairo_get_target(context()->platformContext()); 111 if (!image) 112 return "data:,"; 113 114 String actualMimeType("image/png"); 115 if (MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)) 116 actualMimeType = mimeType; 117 118 Vector<char> in; 119 // Only PNG output is supported for now. 120 cairo_surface_write_to_png_stream(image, writeFunction, &in); 121 122 Vector<char> out; 123 base64Encode(in, out); 124 125 return "data:" + actualMimeType + ";base64," + String(out.data(), out.size()); 101 126 } 102 127
Note: See TracChangeset
for help on using the changeset viewer.