10#include <QApplication>
17#include <QRegularExpression>
41 , m_batchMode(batchMode)
60 float framerate = 24.0;
61 float pixelRatio = 1.0;
66 int frameCountIdx = -1;
67 int framerateIdx = -1;
68 int pixelRatioIdx = -1;
72 KisCursorOverrideLock cursorLock(Qt::WaitCursor);
74 idx = filename.lastIndexOf(QRegularExpression(
"[\\/]"));
75 QString base = (idx == -1) ? QString() : filename.left(idx + 1);
76 QString path = filename;
78 if (path.right(4).toUpper() ==
".CSV")
79 path = path.left(path.size() - 4);
82 path.append(
".frames/");
90 importDoc->setInfiniteAutoSaveInterval();
91 importDoc->setFileBatchMode(
true);
121 qApp->processEvents();
128 if ((idx = readLine.
nextLine(io)) <= 0) {
129 if ((idx < 0) ||(step < 5))
135 if (field.isNull())
continue;
146 for (idx = 0; !field.isNull(); idx++) {
147 if (field ==
"Project Name") {
150 }
else if (field ==
"Width") {
153 }
else if (field ==
"Height") {
156 }
else if (field ==
"Frame Count") {
159 }
else if (field ==
"Frame Rate") {
162 }
else if (field ==
"Pixel Aspect Ratio") {
172 for (idx= 0; !field.isNull(); idx++) {
173 if (idx == projNameIdx) {
176 }
else if (idx == widthIdx) {
177 width = field.toInt();
179 }
else if (idx == heightIdx) {
180 height = field.toInt();
182 }
else if (idx == frameCountIdx) {
183 frameCount = field.toInt();
185 if (frameCount < 1) frameCount= 1;
187 }
else if (idx == framerateIdx) {
188 framerate = field.toFloat();
190 }
else if (idx == pixelRatioIdx) {
191 pixelRatio = field.toFloat();
197 if ((width < 1) || (height < 1)) {
202 retval =
createNewImage(width, height, pixelRatio, projName.isNull() ? filename : projName);
206 if (field[0] !=
'#')
break;
208 for (; !(field = readLine.
nextField()).isNull(); ) {
210 layers.append(layerRecord);
219 if (field ==
"#Layers") {
221 for (idx = 0; !(field = readLine.
nextField()).isNull() && (idx < layers.size()); idx++)
222 layers.at(idx)->name = field;
226 if (field ==
"#Density") {
228 for (idx = 0; !(field = readLine.
nextField()).isNull() && (idx < layers.size()); idx++)
229 layers.at(idx)->density = field.toFloat();
233 if (field ==
"#Blending") {
235 for (idx = 0; !(field = readLine.
nextField()).isNull() && (idx < layers.size()); idx++)
236 layers.at(idx)->blending = field;
240 if (field ==
"#Visible") {
242 for (idx = 0; !(field = readLine.
nextField()).isNull() && (idx < layers.size()); idx++)
243 layers.at(idx)->visible = field.toInt();
247 if (field ==
"#Folder") {
249 for (idx = 0; !(field = readLine.
nextField()).isNull() && (idx < layers.size()); idx++)
250 layers.at(idx)->path =
validPath(field, base);
254 if ((field.size() < 2) || (field[0] !=
'#') || !field[1].isDigit())
break;
262 if ((field.size() < 2) || (field[0] !=
'#') || !field[1].isDigit())
break;
264 for (idx = 0; !(field = readLine.
nextField()).isNull() && (idx < layers.size()); idx++) {
267 if (layer->
last != field) {
272 retval =
setLayer(layer, importDoc.data(), path);
274 layer->
frame = frame;
280 }
while (retval.
isOk());
288 if (frame > frameCount)
295 for (idx = 0; idx < layers.size(); idx++) {
299 if ((layer->
frame > 0) || !layer->
last.isEmpty()) {
300 retval =
setLayer(layer, importDoc.data(), path);
310 for (idx = layers.size() - 1; idx >= 0; idx--) {
375 QString tryPath= QString(path).replace(QString(
"\\"), QString(
"/"));
376 int i = tryPath.lastIndexOf(
"/");
378 if (i == (tryPath.size() - 1))
379 tryPath= tryPath.left(i);
381 if (QFileInfo(tryPath).isDir())
382 return tryPath.append(
"/");
384 QString scan(tryPath);
387 while ((i= (scan.lastIndexOf(
"/",i) - 1)) > 0) {
390 if ((i >= 6) && (scan.mid(i - 6, 7) ==
".layers"))
continue;
392 tryPath= QString(base).append(scan.mid(i + 2));
394 if (QFileInfo(tryPath).isDir())
395 return tryPath.append(
"/");
407 float opacity = layer->
density;
411 else if (opacity < 0.0)
424 layer->
layer = paintLayer;
425 layer->
channel = qobject_cast<KisRasterKeyframeChannel*>
430 if (!layer->
last.isEmpty()) {
432 QString filename = layer->
path.isNull() ? path : layer->
path;
433 filename.append(layer->
last);
435 result = importDoc->
openPath(filename,
467 return decode(io, filename);
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
const quint8 OPACITY_OPAQUE_U8
const QString COMPOSITE_OVER
const QString COMPOSITE_DARKEN
const QString COMPOSITE_OVERLAY
const QString COMPOSITE_DIVIDE
const QString COMPOSITE_DODGE
const QString COMPOSITE_ADD
const QString COMPOSITE_LIGHTEN
const QString COMPOSITE_GRAIN_MERGE
const QString COMPOSITE_SOFT_LIGHT_PHOTOSHOP
const QString COMPOSITE_INVERSE_SUBTRACT
const QString COMPOSITE_MULT
const QString COMPOSITE_SATURATION
const QString COMPOSITE_LINEAR_LIGHT
const QString COMPOSITE_COLORIZE
const QString COMPOSITE_HARD_LIGHT
const QString COMPOSITE_SCREEN
const QString COMPOSITE_DIFF
const QString COMPOSITE_ERASE
const QString COMPOSITE_HUE
const QString COMPOSITE_BEHIND
const QString COMPOSITE_SUBTRACT
const QString COMPOSITE_BURN
const QString COMPOSITE_GRAIN_EXTRACT
KisRasterKeyframeChannel * channel
KisImportExportErrorCode buildAnimation(QIODevice *io, const QString &filename)
QString convertBlending(const QString &)
KisImportExportErrorCode setLayer(CSVLayerRecord *, KisDocument *, const QString &)
QString validPath(const QString &, const QString &)
KisImportExportErrorCode decode(QIODevice *io, const QString &filename)
CSVLoader(KisDocument *doc, bool batchMode)
KisImportExportErrorCode createNewImage(int, int, float, const QString &)
int nextLine(QIODevice *io)
void clearStatusBarMessage()
KisUndoStore * createUndoStore()
bool openPath(const QString &path, OpenFlags flags=None)
openPath Open a Path
void setDocumentRange(const KisTimeSpan range)
void setFramerate(int fps)
const KoColorSpace * colorSpace() const
KisImageAnimationInterface * animationInterface() const
QString nextLayerName(const QString &baseName="") const
void barrierLock(bool readOnly=false)
Wait until all the queued background jobs are completed and lock the image.
KisPaintDeviceSP projection() const
void setResolution(double xres, double yres)
void addKeyframe(int time, KUndo2Command *parentUndoCmd=nullptr)
Add a new keyframe to the channel at the specified time.
static KisPart * instance()
KisMainWindow * currentMainwindow() const
void importFrame(int time, KisPaintDeviceSP sourceDevice, KUndo2Command *parentCommand)
static KisTimeSpan fromTimeToTime(int start, int end)
KisDocument * createDocument(QList< KisNodeSP > nodes, KisImageSP srcImage, const QRect &copiedBounds)
virtual void setVisible(bool visible, bool loading=false)
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)
void setCompositeOpId(const QString &compositeOpId)
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
static KoColorSpaceRegistry * instance()