2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc.
4 * Copyright (C) 2009 Holger Hans Peter Freyther
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include "ImageDecoder.h"
31 #include "NotImplemented.h"
38 RGBA32Buffer::RGBA32Buffer()
41 , m_status(FrameEmpty)
43 , m_disposalMethod(DisposeNotSpecified)
47 RGBA32Buffer& RGBA32Buffer::operator=(const RGBA32Buffer& other)
52 copyBitmapData(other);
53 setRect(other.rect());
54 setStatus(other.status());
55 setDuration(other.duration());
56 setDisposalMethod(other.disposalMethod());
60 void RGBA32Buffer::clear()
64 m_status = FrameEmpty;
65 // NOTE: Do not reset other members here; clearFrameBufferCache()
66 // calls this to free the bitmap data, but other functions like
67 // initFrameBuffer() and frameComplete() may still need to read
68 // other metadata out of this frame later.
71 void RGBA32Buffer::zeroFill()
73 if (m_pixmap.isNull() && !m_image.isNull()) {
74 m_pixmap = QPixmap(m_image.width(), m_image.height());
77 m_pixmap.fill(QColor(0, 0, 0, 0));
80 bool RGBA32Buffer::copyBitmapData(const RGBA32Buffer& other)
85 m_image = other.m_image;
86 m_pixmap = other.m_pixmap;
87 m_size = other.m_size;
88 m_hasAlpha = other.m_hasAlpha;
92 bool RGBA32Buffer::setSize(int newWidth, int newHeight)
94 // This function should only be called once, it will leak memory
96 ASSERT(width() == 0 && height() == 0);
98 m_size = IntSize(newWidth, newHeight);
100 m_pixmap = QPixmap(newWidth, newHeight);
101 if (m_pixmap.isNull())
110 QPixmap* RGBA32Buffer::asNewNativeImage() const
112 if (m_pixmap.isNull() && !m_image.isNull()) {
113 m_pixmap = QPixmap::fromImage(m_image);
116 return new QPixmap(m_pixmap);
119 bool RGBA32Buffer::hasAlpha() const
124 void RGBA32Buffer::setHasAlpha(bool alpha)
129 void RGBA32Buffer::setColorProfile(const ColorProfile& colorProfile)
134 void RGBA32Buffer::setStatus(FrameStatus status)
139 // The image must not have format 8888 pre multiplied...
140 void RGBA32Buffer::setPixmap(const QPixmap& pixmap)
144 m_size = pixmap.size();
145 m_hasAlpha = pixmap.hasAlphaChannel();
148 int RGBA32Buffer::width() const
150 return m_size.width();
153 int RGBA32Buffer::height() const
155 return m_size.height();