diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
commit | 635860845790a19bf50bbc51ba8fb66a96dde068 (patch) | |
tree | ef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/platform/graphics/qt/ImageDecoderQt.cpp | |
parent | 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff) | |
download | external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2 |
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/platform/graphics/qt/ImageDecoderQt.cpp')
-rw-r--r-- | WebCore/platform/graphics/qt/ImageDecoderQt.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp index e3b00a1..394c7a7 100644 --- a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp +++ b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp @@ -178,9 +178,26 @@ ImageDecoderQt::ReadContext::IncrementalReadResult return IncrementalReadComplete; } +ImageDecoderQt* ImageDecoderQt::create(const SharedBuffer& data) +{ + // We need at least 4 bytes to figure out what kind of image we're dealing with. + if (data.size() < 4) + return 0; + + QByteArray bytes = QByteArray::fromRawData(data.data(), data.size()); + QBuffer buffer(&bytes); + if (!buffer.open(QBuffer::ReadOnly)) + return 0; + + QString imageFormat = QString::fromLatin1(QImageReader::imageFormat(&buffer).toLower()); + if (imageFormat.isEmpty()) + return 0; // Image format not supported + + return new ImageDecoderQt(imageFormat); +} -// ImageDecoderQt -ImageDecoderQt::ImageDecoderQt( ) +ImageDecoderQt::ImageDecoderQt(const QString &imageFormat) + : m_imageFormat(imageFormat) { } @@ -254,7 +271,6 @@ int ImageDecoderQt::frameCount() const return m_imageList.size(); } - int ImageDecoderQt::repetitionCount() const { if (debugImageDecoderQt) @@ -262,7 +278,6 @@ int ImageDecoderQt::repetitionCount() const return m_loopCount; } - bool ImageDecoderQt::supportsAlpha() const { return hasFirstImageHeader() && m_imageList[0].m_image.hasAlphaChannel(); @@ -275,6 +290,13 @@ int ImageDecoderQt::duration(size_t index) const return m_imageList[index].m_duration; } +String ImageDecoderQt::filenameExtension() const +{ + if (debugImageDecoderQt) + qDebug() << " ImageDecoderQt::filenameExtension() returns" << m_imageFormat; + return m_imageFormat; +}; + RGBA32Buffer* ImageDecoderQt::frameBufferAtIndex(size_t index) { Q_ASSERT("use imageAtIndex instead"); |