The filter chain calls this method to perform the actual conversion. The passed mimetypes should be a pair of those you specified in your .desktop file. You have to implement this method to make the filter work.
92{
93#if KDCRAW_VERSION < 0x010200
95#else
97#endif
98
99 int r = QDialog::Accepted;
102 }
103
104 if (r == QDialog::Accepted) {
105 KisCursorOverrideLock cursorLock(Qt::WaitCursor);
106
107
108 QByteArray imageData;
110 settings.sixteenBitsImage = true;
111 int width = 0;
112 int height = 0;
113 int rgbmax = 0;
115 if (!dcraw.decodeRAWImage(
filename(), settings, imageData, width, height, rgbmax))
117
119
120 switch (settings.outputColorSpace) {
121 case RawDecodingSettings::RAWCOLOR:
122 case RawDecodingSettings::SRGB:
124 break;
125 case RawDecodingSettings::ADOBERGB:
127 break;
128 case RawDecodingSettings::WIDEGAMMUT:
130 break;
131 case RawDecodingSettings::PROPHOTO:
133 break;
134 case RawDecodingSettings::CUSTOMOUTPUTCS:
135 QFileInfo info(settings.outputProfile);
136
137 if (!info.exists()) {
138 qWarning() << "WARNING: couldn't find custom profile" << settings.outputProfile;
140 } else {
141 QFile profileFile(settings.outputProfile);
142
143 if (profileFile.open(QFile::ReadOnly)) {
146 profileFile.readAll());
147 } else {
148 qWarning() << "WARNING: couldn't open custom profile file" << settings.outputProfile;
149 }
150 }
151
152 if (!profile) {
153 qWarning() << "WARNING: reset profile to sRGB";
155 }
156
157 break;
158 }
159
160
164
166
169
172
174 const QByteArray &imageData,
175 int width,
176 int height,
178 const float original =
static_cast<float>(
updater->progress());
179
180 const float step = (
static_cast<float>(
updater->maximum() * 0.9) - original) / (float)height;
181
183
184 for (
int y = 0;
y < height;) {
186 for (
int x = 0;
x < width;) {
188
190
191 const int rowStride = it->
rowStride(x, y);
192
194
195 for (int i = 0; i < numContiguousRows; i++) {
196 const auto *ptr =
198 + static_cast<ptrdiff_t>(((y + i) * width + x) * 3);
199
200 for (int j = 0; j < numContiguousColumns; j++) {
201 auto *pixel =
reinterpret_cast<typename KoBgrU16Traits::Pixel *
>(
d) + j;
202#if KDCRAW_VERSION < 0x000400
206 pixel->alpha = 0xFFFF;
207#else
209#endif
210 ptr += 3;
211 }
212
214 }
215
216 x += numContiguousColumns;
217 }
218
219 y += numContiguousRows;
220 updater->setProgress(
static_cast<int>(original + step *
float(y)));
221 }
222 };
223
225
226 {
227
228
229 try {
231
232#if EXIV2_TEST_VERSION(0,28,0)
233 const std::unique_ptr<Exiv2::Image> readImg = Exiv2::ImageFactory::open(std::move(basicIoDevice));
234#else
235 const std::unique_ptr<Exiv2::Image> readImg(Exiv2::ImageFactory::open(basicIoDevice).release());
236#endif
237
238 readImg->readMetadata();
239
241
242
244
245 QBuffer ioDevice;
246
247 {
248
249 Exiv2::ExifData tempData;
250 Exiv2::Blob tempBlob;
251
252
253 for (const Exiv2::Exifdatum &i : readImg->exifData()) {
254 const uint16_t tag = i.tag();
255
266 dbgMetaData <<
"Ignoring TIFF-specific" << i.key().c_str();
267 continue;
268 }
269
270 tempData.add(i);
271 }
272
273
274 Exiv2::ExifParser::encode(tempBlob, Exiv2::littleEndian, tempData);
275
276
277 ioDevice.setData(reinterpret_cast<char *>(tempBlob.data()), static_cast<int>(tempBlob.size()));
278 }
279
280
281 KisLayer *layer = qobject_cast<KisLayer *>(node.
data());
283 {
284 errFile <<
"Attempted to import metadata on an empty document";
286 }
287
288
290#if EXIV2_TEST_VERSION(0,28,0)
291 } catch (Exiv2::Error &e) {
292 errFile <<
"Failed injecting TIFF metadata:" << Exiv2::Error(e.code()).what();
293#else
294 } catch (Exiv2::AnyError &e) {
295 errFile <<
"Failed metadata import:" << e.code() << e.what();
296#endif
297 }
298 }
299
300 document->setCurrentImage(image);
303 }
304
306}
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
virtual quint8 * rawData()=0
Exiv2::BasicIo::AutoPtr ptr_type
KisGroupLayerSP rootLayer() const
QString nextLayerName(const QString &baseName="") const
QPointer< KoUpdater > updater
KisRandomAccessorSP createRandomAccessorNG()
virtual qint32 rowStride(qint32 x, qint32 y) const =0
virtual qint32 numContiguousRows(qint32 y) const =0
virtual void moveTo(qint32 x, qint32 y)=0
virtual qint32 numContiguousColumns(qint32 x) const =0
KDcrawIface::RawDecodingSettings rawDecodingSettings()
const T value(const QString &id) const
#define KIS_ASSERT_RECOVER_RETURN_VALUE(cond, val)
#define KIS_ASSERT_RECOVER(cond)
quint16 correctIndian(quint16 v)
const uint16_t ImageLength
const uint16_t PrimaryChromaticities
const uint16_t ReferenceBlackWhite
const uint16_t ImageWidth
const uint16_t PlanarConfiguration
const uint16_t YResolution
const uint16_t XResolution
const uint16_t TransferFunction
const uint16_t Orientation
const uint16_t ResolutionUnit
const uint16_t YCbCrSubSampling
const uint16_t SamplesPerPixel
const uint16_t BitsPerSample
const uint16_t Compression
const uint16_t InterColorProfile
const uint16_t YCbCrCoefficients
const uint16_t YCbCrPositioning
const uint16_t WhitePoint
const uint16_t PhotometricInterpretation
void readLayer(const int width, const int height, KisHLineIteratorSP it, const uint8_t *imgG, const uint8_t *imgA, const int strideG, const int strideA)
virtual KisPaintDeviceSP paintDevice() const =0
KisMetaData::Store * metaData()
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
KisNodeSP firstChild() const
KisPaintDeviceSP paintDevice
const KoColorProfile * profileByName(const QString &name) const
static KoColorSpaceRegistry * instance()
const KoColorProfile * p709SRGBProfile() const
const KoColorSpace * rgb16(const QString &profileName=QString())
const KoColorProfile * createColorProfile(const QString &colorModelId, const QString &colorDepthId, const QByteArray &rawData)
_channels_type_ channels_type
the type of the value of the channels of this color space