Krita Source Code Documentation
Loading...
Searching...
No Matches
KisReferenceImage::Private Struct Reference
+ Inheritance diagram for KisReferenceImage::Private:

Public Member Functions

bool loadFromFile ()
 
bool loadFromQImage (const QImage &img)
 
void updateCache ()
 

Public Attributes

QImage cachedImage
 
bool embed {true}
 
QString externalFilename
 
int id {-1}
 
QImage image
 
QString internalFilename
 
KisQImagePyramid mipmap
 
qreal saturation {1.0}
 

Detailed Description

Definition at line 38 of file KisReferenceImage.cpp.

Member Function Documentation

◆ loadFromFile()

bool KisReferenceImage::Private::loadFromFile ( )
inline

Definition at line 54 of file KisReferenceImage.cpp.

54 {
57 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(QFileInfo(externalFilename).isReadable(), false);
58 {
59 QImageReader reader(externalFilename);
60 reader.setDecideFormatFromContent(true);
61 image = reader.read();
62
63 if (image.isNull()) {
64 reader.setAutoDetectImageFormat(true);
65 image = reader.read();
66 }
67
68 }
69
70 if (image.isNull()) {
72 }
73
74 if (image.isNull()) {
77 if (doc->image()->colorSpace()->colorModelId() == RGBAColorModelID) {
79 // Because we store as PNG, we'll need to convert to PQ here. One problem: we need to check when saving the reference images.
82 }
83 image = doc->image()->convertToQImage(doc->image()->bounds(), doc->image()->colorSpace()->profile());
84 image.setColorSpace(KoColorSpaceRegistry::instance()->QColorSpaceForProfile(doc->image()->colorSpace()->profile()));
85 } else {
86 image = doc->image()->convertToQImage(doc->image()->bounds(), 0);
87 }
88 }
90 }
91
92 // See https://bugs.kde.org/show_bug.cgi?id=416515 -- a jpeg image
93 // loaded into a qimage cannot be saved to png unless we explicitly
94 // convert the colorspace of the QImage
95#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
96 if (image.colorSpace().colorModel() != QColorSpace::ColorModel::Rgb || !image.colorSpace().isValid()) {
97 image.convertToColorSpace(QColorSpace(QColorSpace::SRgb));
98 }
99#else
100 image.convertToColorSpace(QColorSpace(QColorSpace::SRgb));
101#endif
102
103 return (!image.isNull());
104 }
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
KisImageSP image
bool openPath(const QString &path, OpenFlags flags=None)
openPath Open a Path
QImage convertToQImage(qint32 x1, qint32 y1, qint32 width, qint32 height, const KoColorProfile *profile)
const KoColorSpace * colorSpace() const
void convertImageColorSpace(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
QRect bounds() const override
static KisPart * instance()
Definition KisPart.cpp:131
void removeDocument(KisDocument *document, bool deleteDocument=true)
Definition KisPart.cpp:248
KisDocument * createTemporaryDocument() const
Definition KisPart.cpp:236
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
virtual const KoColorProfile * profile() const =0
QString id() const
Definition KoID.cpp:63
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()
const KoColorProfile * p2020PQProfile() const

References KisImage::bounds(), KoColorSpace::colorDepthId(), KoColorSpace::colorModelId(), KisImage::colorSpace(), KoColorSpaceRegistry::colorSpace(), KisImage::convertImageColorSpace(), KisImage::convertToQImage(), KisPart::createTemporaryDocument(), KisDocument::DontAddToRecent, externalFilename, Float16BitsColorDepthID, Float32BitsColorDepthID, KoID::id(), KisDocument::image, image, KoColorSpaceRegistry::instance(), KisPart::instance(), Integer16BitsColorDepthID, KoColorConversionTransformation::IntentRelativeColorimetric, KoColorConversionTransformation::internalConversionFlags(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, KisDocument::openPath(), KoColorSpaceRegistry::p2020PQProfile(), KoColorSpace::profile(), KisPart::removeDocument(), and RGBAColorModelID.

◆ loadFromQImage()

bool KisReferenceImage::Private::loadFromQImage ( const QImage & img)
inline

Definition at line 106 of file KisReferenceImage.cpp.

106 {
107 image = img;
108 return !image.isNull();
109 }

References image.

◆ updateCache()

void KisReferenceImage::Private::updateCache ( )
inline

Definition at line 111 of file KisReferenceImage.cpp.

111 {
112 if (saturation < 1.0) {
114
115 if (saturation > 0.0) {
116 QPainter gc2(&cachedImage);
117 gc2.setOpacity(saturation);
118 gc2.drawImage(QPoint(), image);
119 }
120 } else {
122 }
123
125 }
QImage convertQImageToGrayA(const QImage &image)

References cachedImage, KritaUtils::convertQImageToGrayA(), image, mipmap, and saturation.

Member Data Documentation

◆ cachedImage

QImage KisReferenceImage::Private::cachedImage

Definition at line 47 of file KisReferenceImage.cpp.

◆ embed

bool KisReferenceImage::Private::embed {true}

Definition at line 52 of file KisReferenceImage.cpp.

52{true};

◆ externalFilename

QString KisReferenceImage::Private::externalFilename

Definition at line 44 of file KisReferenceImage.cpp.

◆ id

int KisReferenceImage::Private::id {-1}

Definition at line 51 of file KisReferenceImage.cpp.

51{-1};

◆ image

QImage KisReferenceImage::Private::image

Definition at line 46 of file KisReferenceImage.cpp.

◆ internalFilename

QString KisReferenceImage::Private::internalFilename

Definition at line 41 of file KisReferenceImage.cpp.

◆ mipmap

KisQImagePyramid KisReferenceImage::Private::mipmap

Definition at line 48 of file KisReferenceImage.cpp.

◆ saturation

qreal KisReferenceImage::Private::saturation {1.0}

Definition at line 50 of file KisReferenceImage.cpp.

50{1.0};

The documentation for this struct was generated from the following file: