void ApiSurface::contentsFromBase64(const QByteArray &base64)
{
- QByteArray dataArray = QByteArray::fromBase64(base64);
+ m_base64Data = base64;
+
+ /*
+ * We need to do the conversion to create the thumbnail
+ */
+ image::Image *image = imageFromBase64(base64);
+ Q_ASSERT(image);
+ QImage img = qimageFromRawImage(image);
+ m_thumb = thumbnail(img);
+ delete image;
+}
+
+QByteArray ApiSurface::base64Data() const
+{
+ return m_base64Data;
+}
+
+QImage ApiSurface::thumb() const
+{
+ return m_thumb;
+}
+
+int ApiSurface::depth() const
+{
+ return m_depth;
+}
+
+void ApiSurface::setDepth(int depth)
+{
+ m_depth = depth;
+}
+
+QString ApiSurface::formatName() const
+{
+ return m_formatName;
+}
+
+void ApiSurface::setFormatName(const QString &str)
+{
+ m_formatName = str;
+}
+
+
+ApiTexture::ApiTexture()
+ : ApiSurface()
+{
+}
+
+QString ApiTexture::label() const
+{
+ return m_label;
+}
+
+void ApiTexture::setLabel(const QString &str)
+{
+ m_label = str;
+}
+ApiFramebuffer::ApiFramebuffer()
+ : ApiSurface()
+{
+}
+
+QString ApiFramebuffer::type() const
+{
+ return m_type;
+}
+
+void ApiFramebuffer::setType(const QString &str)
+{
+ m_type = str;
+}
+
+image::Image *
+ApiSurface::imageFromBase64(const QByteArray &base64)
+{
+ QByteArray dataArray = QByteArray::fromBase64(base64);
image::Image *image;
/*
image = image::readPNM(dataArray.data(), dataArray.size());
}
- /*
- * FIXME: Instead of converting to QImage here, we should be deferring the conversion
- * to imageviewer.cpp.
- *
- * XXX: We still need the thumbnail though.
- */
+ return image;
+}
- Q_ASSERT(image);
+QImage
+ApiSurface::qimageFromRawImage(const image::Image *image)
+{
+ QImage img;
int width = image->width;
int height = image->height;
- m_image = QImage(width, height, QImage::Format_ARGB32);
+ img = QImage(width, height, QImage::Format_ARGB32);
const unsigned char *srcRow = image->start();
for (int y = 0; y < height; ++y) {
- QRgb *dst = (QRgb *)m_image.scanLine(y);
+ QRgb *dst = (QRgb *)img.scanLine(y);
if (image->channelType == image::TYPE_UNORM8) {
const unsigned char *src = srcRow;
srcRow += image->stride();
}
- delete image;
-
- m_thumb = thumbnail(m_image);
-}
-
-QImage ApiSurface::image() const
-{
- return m_image;
-}
-
-QImage ApiSurface::thumb() const
-{
- return m_thumb;
-}
-
-int ApiSurface::depth() const
-{
- return m_depth;
+ return img;
}
-
-void ApiSurface::setDepth(int depth)
-{
- m_depth = depth;
-}
-
-QString ApiSurface::formatName() const
-{
- return m_formatName;
-}
-
-void ApiSurface::setFormatName(const QString &str)
-{
- m_formatName = str;
-}
-
-
-ApiTexture::ApiTexture()
- : ApiSurface()
-{
-}
-
-QString ApiTexture::label() const
-{
- return m_label;
-}
-
-void ApiTexture::setLabel(const QString &str)
-{
- m_label = str;
-}
-
-ApiFramebuffer::ApiFramebuffer()
- : ApiSurface()
-{
-}
-
-QString ApiFramebuffer::type() const
-{
- return m_type;
-}
-
-void ApiFramebuffer::setType(const QString &str)
-{
- m_type = str;
-}
-