gif record fixes
This commit is contained in:
@@ -251,7 +251,7 @@ void Graphic::timerEvent(QTimerEvent * e) {
|
|||||||
if (e->timerId() == timer_record) {
|
if (e->timerId() == timer_record) {
|
||||||
QPixmap im(canvas->size());
|
QPixmap im(canvas->size());
|
||||||
canvas->render(&im);
|
canvas->render(&im);
|
||||||
record_imgs << im.toImage();
|
record_imgs << im.toImage().convertToFormat(QImage::Format_Indexed8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1934,6 +1934,7 @@ void Graphic::on_graphic_buttonRecord_clicked(bool checked) {
|
|||||||
if (record_imgs.isEmpty()) return;
|
if (record_imgs.isEmpty()) return;
|
||||||
QString f = QFileDialog::getSaveFileName(this, tr("Save GIF"), ppath, "GIF(*.gif)");
|
QString f = QFileDialog::getSaveFileName(this, tr("Save GIF"), ppath, "GIF(*.gif)");
|
||||||
if (!f.isEmpty()) {
|
if (!f.isEmpty()) {
|
||||||
|
qApp->setOverrideCursor(Qt::BusyCursor);
|
||||||
GifWriter gif_writer;
|
GifWriter gif_writer;
|
||||||
int frame_delay = 10;
|
int frame_delay = 10;
|
||||||
if (GifBegin(&gif_writer, f.toUtf8(), static_cast<uint32_t>(record_imgs.first().width()),
|
if (GifBegin(&gif_writer, f.toUtf8(), static_cast<uint32_t>(record_imgs.first().width()),
|
||||||
@@ -1941,7 +1942,7 @@ void Graphic::on_graphic_buttonRecord_clicked(bool checked) {
|
|||||||
static_cast<uint32_t>(frame_delay))) {
|
static_cast<uint32_t>(frame_delay))) {
|
||||||
for (const QImage & im : record_imgs) {
|
for (const QImage & im : record_imgs) {
|
||||||
if (!GifWriteFrame(&gif_writer,
|
if (!GifWriteFrame(&gif_writer,
|
||||||
im.convertToFormat(QImage::Format_Indexed8).convertToFormat(QImage::Format_RGBA8888).constBits(),
|
im.convertToFormat(QImage::Format_RGBA8888).constBits(),
|
||||||
static_cast<uint32_t>(im.width()),
|
static_cast<uint32_t>(im.width()),
|
||||||
static_cast<uint32_t>(im.height()),
|
static_cast<uint32_t>(im.height()),
|
||||||
static_cast<uint32_t>(frame_delay))) {
|
static_cast<uint32_t>(frame_delay))) {
|
||||||
@@ -1951,6 +1952,7 @@ void Graphic::on_graphic_buttonRecord_clicked(bool checked) {
|
|||||||
}
|
}
|
||||||
GifEnd(&gif_writer);
|
GifEnd(&gif_writer);
|
||||||
}
|
}
|
||||||
|
qApp->restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
record_imgs.clear();
|
record_imgs.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user