Skip to content

Commit fc9f78f

Browse files
committed
support PCX images II.
1 parent a0d69aa commit fc9f78f

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

source/celview.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,26 @@ void CelView::insertFrame(IMAGE_FILE_MODE mode, int index, const QString &imagef
305305

306306
void CelView::replaceCurrentFrame(const QString &imagefilePath)
307307
{
308+
if (imagefilePath.toLower().endsWith(".pcx")) {
309+
bool clipped = this->gfx->getFrame(this->currentFrameIndex)->isClipped(), palMod;
310+
D1GfxFrame frame;
311+
bool success = D1Pcx::load(frame, imagefilePath, clipped, this->pal, this->gfx->getPalette(), &palMod);
312+
if (!success) {
313+
dProgressFail() << tr("Failed to load file: %1.").arg(imagefilePath);
314+
return;
315+
}
316+
this->gfx->setFrame(this->currentFrameIndex, frame);
317+
318+
if (palMod) {
319+
// update the palette
320+
emit this->palModified();
321+
}
322+
// update the view
323+
this->update();
324+
this->displayFrame();
325+
return;
326+
}
327+
308328
QImage image = QImage(imagefilePath);
309329

310330
if (image.isNull()) {

source/d1gfx.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,6 @@ D1GfxFrame *D1Gfx::insertFrame(int idx, bool *clipped)
141141
}
142142

143143
this->frames.insert(idx, D1GfxFrame());
144-
this->modified = true;
145-
return &this->frames[idx];
146-
}
147-
148-
D1GfxFrame *D1Gfx::insertFrame(int idx, const QImage &image)
149-
{
150-
bool clipped;
151-
152-
D1GfxFrame *frame = this->insertFrame(idx, &clipped);
153-
D1ImageFrame::load(*frame, image, clipped, this->palette);
154-
// this->modified = true;
155144

156145
if (this->groupFrameIndices.isEmpty()) {
157146
// create new group if this is the first frame
@@ -170,6 +159,19 @@ D1GfxFrame *D1Gfx::insertFrame(int idx, const QImage &image)
170159
this->groupFrameIndices[i].second++;
171160
}
172161
}
162+
163+
this->modified = true;
164+
return &this->frames[idx];
165+
}
166+
167+
D1GfxFrame *D1Gfx::insertFrame(int idx, const QImage &image)
168+
{
169+
bool clipped;
170+
171+
D1GfxFrame *frame = this->insertFrame(idx, &clipped);
172+
D1ImageFrame::load(*frame, image, clipped, this->palette);
173+
// this->modified = true;
174+
173175
return &this->frames[idx];
174176
}
175177

source/mainwindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,8 @@ static QString imageNameFilter()
961961
}
962962
}
963963
// add PCX support
964-
allSupportedFormats.append(".pcx");
965-
allSupportedFormats.append(".PCX");
964+
allSupportedFormats.append("*.pcx");
965+
allSupportedFormats.append("*.PCX");
966966

967967
QString allSupportedFormatsFilter = QApplication::tr("Image files (%1)").arg(allSupportedFormats.join(' '));
968968
return allSupportedFormatsFilter;

0 commit comments

Comments
 (0)