Commit 411f3ba4 authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by Scott Petrovic

Add KoColorDisplayRendererInterface::toQImage

This converts a whole array of pixels to a QImage.
parent 3b2b30d9
......@@ -23,6 +23,8 @@
#include <KoColorSpaceRegistry.h>
#include <KoChannelInfo.h>
#include <KoColorConversionTransformation.h>
#include <KoColorSpace.h>
Q_GLOBAL_STATIC(KoDumbColorDisplayRenderer, s_instance)
......@@ -34,6 +36,11 @@ KoColorDisplayRendererInterface::~KoColorDisplayRendererInterface()
{
}
QImage KoDumbColorDisplayRenderer::convertToQImage(const KoColorSpace *srcColorSpace, const quint8 *data, qint32 width, qint32 height) const
{
return srcColorSpace->convertToQImage(data, width, height, 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
}
QColor KoDumbColorDisplayRenderer::toQColor(const KoColor &c) const
{
return c.toQColor();
......
......@@ -27,6 +27,7 @@
#include "KoColor.h"
class KoChannelInfo;
class KoColorSpace;
/**
* A special interface class provided by pigment to let widgets render
......@@ -44,6 +45,16 @@ public:
KoColorDisplayRendererInterface();
virtual ~KoColorDisplayRendererInterface();
/**
* @brief KoColorSpace::convertToQImage converts a whole row of colors in one go
* @param srcColorSpace the colorspace the pixel data is in
* @param data a pointer to a byte array with colors
* @param width of the resulting image
* @param height of the resulting image
* @return a QImage that can be displayed
*/
virtual QImage convertToQImage(const KoColorSpace *srcColorSpace, const quint8 *data, qint32 width, qint32 height) const = 0;
/**
* Convert the color \p c to a custom QColor that will be
* displayed by the widget on screen. Please note, that the
......@@ -101,6 +112,7 @@ private:
class KRITAPIGMENT_EXPORT KoDumbColorDisplayRenderer : public KoColorDisplayRendererInterface
{
public:
QImage convertToQImage(const KoColorSpace *srcColorSpace, const quint8 *data, qint32 width, qint32 height) const;
QColor toQColor(const KoColor &c) const;
KoColor approximateFromRenderedQColor(const QColor &c) const;
KoColor fromHsv(int h, int s, int v, int a = 255) const;
......
......@@ -109,6 +109,12 @@ struct KisDisplayColorConverter::Private
this, SIGNAL(displayConfigurationChanged()));
}
QImage convertToQImage(const KoColorSpace *srcColorSpace, const quint8 *data, qint32 width, qint32 height) const {
KisPaintDeviceSP dev = new KisPaintDevice(srcColorSpace);
dev->writeBytes(data, 0, 0, width, height);
return m_displayColorConverter->toQImage(dev);
}
QColor toQColor(const KoColor &c) const override {
return m_displayColorConverter->toQColor(c);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment