Skip to content

Commit

Permalink
support PCX images II.
Browse files Browse the repository at this point in the history
  • Loading branch information
pionere committed Jan 26, 2023
1 parent a0d69aa commit fc9f78f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
20 changes: 20 additions & 0 deletions source/celview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,26 @@ void CelView::insertFrame(IMAGE_FILE_MODE mode, int index, const QString &imagef

void CelView::replaceCurrentFrame(const QString &imagefilePath)
{
if (imagefilePath.toLower().endsWith(".pcx")) {
bool clipped = this->gfx->getFrame(this->currentFrameIndex)->isClipped(), palMod;
D1GfxFrame frame;
bool success = D1Pcx::load(frame, imagefilePath, clipped, this->pal, this->gfx->getPalette(), &palMod);
if (!success) {
dProgressFail() << tr("Failed to load file: %1.").arg(imagefilePath);
return;
}
this->gfx->setFrame(this->currentFrameIndex, frame);

if (palMod) {
// update the palette
emit this->palModified();
}
// update the view
this->update();
this->displayFrame();
return;
}

QImage image = QImage(imagefilePath);

if (image.isNull()) {
Expand Down
24 changes: 13 additions & 11 deletions source/d1gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,6 @@ D1GfxFrame *D1Gfx::insertFrame(int idx, bool *clipped)
}

this->frames.insert(idx, D1GfxFrame());
this->modified = true;
return &this->frames[idx];
}

D1GfxFrame *D1Gfx::insertFrame(int idx, const QImage &image)
{
bool clipped;

D1GfxFrame *frame = this->insertFrame(idx, &clipped);
D1ImageFrame::load(*frame, image, clipped, this->palette);
// this->modified = true;

if (this->groupFrameIndices.isEmpty()) {
// create new group if this is the first frame
Expand All @@ -170,6 +159,19 @@ D1GfxFrame *D1Gfx::insertFrame(int idx, const QImage &image)
this->groupFrameIndices[i].second++;
}
}

this->modified = true;
return &this->frames[idx];
}

D1GfxFrame *D1Gfx::insertFrame(int idx, const QImage &image)
{
bool clipped;

D1GfxFrame *frame = this->insertFrame(idx, &clipped);
D1ImageFrame::load(*frame, image, clipped, this->palette);
// this->modified = true;

return &this->frames[idx];
}

Expand Down
4 changes: 2 additions & 2 deletions source/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,8 @@ static QString imageNameFilter()
}
}
// add PCX support
allSupportedFormats.append(".pcx");
allSupportedFormats.append(".PCX");
allSupportedFormats.append("*.pcx");
allSupportedFormats.append("*.PCX");

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

0 comments on commit fc9f78f

Please sign in to comment.