mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Code clarity and potential bugfix
This commit is contained in:
parent
a81289a0d7
commit
adcbb0b760
2 changed files with 42 additions and 41 deletions
|
@ -45,50 +45,50 @@ void SnapshotAnimated::saveSnapshotAnimated(bool includeAnimated, QString pathSt
|
||||||
frame = frame.convertToFormat(QImage::Format_RGBA8888);
|
frame = frame.convertToFormat(QImage::Format_RGBA8888);
|
||||||
|
|
||||||
// If this is the first frame...
|
// If this is the first frame...
|
||||||
if (snapshotAnimatedTimestamp == 0)
|
if (SnapshotAnimated::snapshotAnimatedTimestamp == 0)
|
||||||
{
|
{
|
||||||
// Write out the header and beginning of the GIF file
|
// Write out the header and beginning of the GIF file
|
||||||
GifBegin(&(snapshotAnimatedGifWriter), qPrintable(pathAnimatedSnapshot), frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC / 10);
|
GifBegin(&(SnapshotAnimated::snapshotAnimatedGifWriter), qPrintable(pathAnimatedSnapshot), frame.width(), frame.height(), SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC / 10);
|
||||||
// Write the first to the gif
|
// Write the first to the gif
|
||||||
GifWriteFrame(&(snapshotAnimatedGifWriter),
|
GifWriteFrame(&(SnapshotAnimated::snapshotAnimatedGifWriter),
|
||||||
(uint8_t*)frame.bits(),
|
(uint8_t*)frame.bits(),
|
||||||
frame.width(),
|
frame.width(),
|
||||||
frame.height(),
|
frame.height(),
|
||||||
SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC / 10);
|
SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC / 10);
|
||||||
// Record the current frame timestamp
|
// Record the current frame timestamp
|
||||||
snapshotAnimatedTimestamp = QDateTime::currentMSecsSinceEpoch();
|
SnapshotAnimated::snapshotAnimatedTimestamp = QDateTime::currentMSecsSinceEpoch();
|
||||||
snapshotAnimatedFirstFrameTimestamp = snapshotAnimatedTimestamp;
|
SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp = SnapshotAnimated::snapshotAnimatedTimestamp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If that was the last frame...
|
// If that was the last frame...
|
||||||
if ((snapshotAnimatedTimestamp - snapshotAnimatedFirstFrameTimestamp) >= (SNAPSNOT_ANIMATED_DURATION_SECS * 1000))
|
if ((SnapshotAnimated::snapshotAnimatedTimestamp - SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp) >= (SNAPSNOT_ANIMATED_DURATION_SECS * 1000))
|
||||||
{
|
{
|
||||||
// Reset the current frame timestamp
|
|
||||||
snapshotAnimatedTimestamp = 0;
|
|
||||||
snapshotAnimatedFirstFrameTimestamp = 0;
|
|
||||||
// Write out the end of the GIF
|
|
||||||
GifEnd(&(snapshotAnimatedGifWriter));
|
|
||||||
// Stop the snapshot QTimer
|
// Stop the snapshot QTimer
|
||||||
snapshotAnimatedTimer.stop();
|
SnapshotAnimated::snapshotAnimatedTimer.stop();
|
||||||
|
// Reset the current frame timestamp
|
||||||
|
SnapshotAnimated::snapshotAnimatedTimestamp = 0;
|
||||||
|
SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp = 0;
|
||||||
|
// Write out the end of the GIF
|
||||||
|
GifEnd(&(SnapshotAnimated::snapshotAnimatedGifWriter));
|
||||||
|
// Let the dependency manager know that the snapshots have been taken.
|
||||||
emit dm->snapshotTaken(pathStillSnapshot, pathAnimatedSnapshot, false);
|
emit dm->snapshotTaken(pathStillSnapshot, pathAnimatedSnapshot, false);
|
||||||
qDebug() << "still: " << pathStillSnapshot << "anim: " << pathAnimatedSnapshot;
|
|
||||||
//emit dm->snapshotTaken("C:\\Users\\Zach Fox\\Desktop\\hifi-snap-by-zfox-on-2016-11-14_17-07-33.jpg", "C:\\Users\\Zach Fox\\Desktop\\hifi-snap-by-zfox-on-2016-11-14_17-10-02.gif", false);
|
|
||||||
}
|
}
|
||||||
|
// If that was an intermediate frame...
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Variable used to determine how long the current frame took to pack
|
// Variable used to determine how long the current frame took to pack
|
||||||
qint64 framePackStartTime = QDateTime::currentMSecsSinceEpoch();
|
qint64 framePackStartTime = QDateTime::currentMSecsSinceEpoch();
|
||||||
// Write the frame to the gif
|
// Write the frame to the gif
|
||||||
GifWriteFrame(&(snapshotAnimatedGifWriter),
|
GifWriteFrame(&(SnapshotAnimated::snapshotAnimatedGifWriter),
|
||||||
(uint8_t*)frame.bits(),
|
(uint8_t*)frame.bits(),
|
||||||
frame.width(),
|
frame.width(),
|
||||||
frame.height(),
|
frame.height(),
|
||||||
round(((float)(QDateTime::currentMSecsSinceEpoch() - snapshotAnimatedTimestamp + snapshotAnimatedLastWriteFrameDuration)) / 10));
|
round(((float)(QDateTime::currentMSecsSinceEpoch() - SnapshotAnimated::snapshotAnimatedTimestamp + SnapshotAnimated::snapshotAnimatedLastWriteFrameDuration)) / 10));
|
||||||
// Record how long it took for the current frame to pack
|
// Record how long it took for the current frame to pack
|
||||||
snapshotAnimatedLastWriteFrameDuration = QDateTime::currentMSecsSinceEpoch() - framePackStartTime;
|
SnapshotAnimated::snapshotAnimatedLastWriteFrameDuration = QDateTime::currentMSecsSinceEpoch() - framePackStartTime;
|
||||||
// Record the current frame timestamp
|
// Record the current frame timestamp
|
||||||
snapshotAnimatedTimestamp = QDateTime::currentMSecsSinceEpoch();
|
SnapshotAnimated::snapshotAnimatedTimestamp = QDateTime::currentMSecsSinceEpoch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,30 +12,31 @@
|
||||||
|
|
||||||
var paths = [], idCounter = 0, useCheckboxes;
|
var paths = [], idCounter = 0, useCheckboxes;
|
||||||
function addImage(data) {
|
function addImage(data) {
|
||||||
if (data.localPath) {
|
if (!data.localPath) {
|
||||||
var div = document.createElement("DIV"),
|
return;
|
||||||
input = document.createElement("INPUT"),
|
|
||||||
label = document.createElement("LABEL"),
|
|
||||||
img = document.createElement("IMG"),
|
|
||||||
id = "p" + idCounter++;
|
|
||||||
function toggle() { data.share = input.checked; }
|
|
||||||
img.src = data.localPath;
|
|
||||||
div.appendChild(img);
|
|
||||||
data.share = true;
|
|
||||||
if (useCheckboxes) { // I'd rather use css, but the included stylesheet is quite particular.
|
|
||||||
// Our stylesheet(?) requires input.id to match label.for. Otherwise input doesn't display the check state.
|
|
||||||
label.setAttribute('for', id); // cannot do label.for =
|
|
||||||
input.id = id;
|
|
||||||
input.type = "checkbox";
|
|
||||||
input.checked = (id === "p0");
|
|
||||||
input.addEventListener('change', toggle);
|
|
||||||
div.class = "property checkbox";
|
|
||||||
div.appendChild(input);
|
|
||||||
div.appendChild(label);
|
|
||||||
}
|
|
||||||
document.getElementById("snapshot-images").appendChild(div);
|
|
||||||
paths.push(data);
|
|
||||||
}
|
}
|
||||||
|
var div = document.createElement("DIV"),
|
||||||
|
input = document.createElement("INPUT"),
|
||||||
|
label = document.createElement("LABEL"),
|
||||||
|
img = document.createElement("IMG"),
|
||||||
|
id = "p" + idCounter++;
|
||||||
|
function toggle() { data.share = input.checked; }
|
||||||
|
img.src = data.localPath;
|
||||||
|
div.appendChild(img);
|
||||||
|
data.share = true;
|
||||||
|
if (useCheckboxes) { // I'd rather use css, but the included stylesheet is quite particular.
|
||||||
|
// Our stylesheet(?) requires input.id to match label.for. Otherwise input doesn't display the check state.
|
||||||
|
label.setAttribute('for', id); // cannot do label.for =
|
||||||
|
input.id = id;
|
||||||
|
input.type = "checkbox";
|
||||||
|
input.checked = (id === "p0");
|
||||||
|
input.addEventListener('change', toggle);
|
||||||
|
div.class = "property checkbox";
|
||||||
|
div.appendChild(input);
|
||||||
|
div.appendChild(label);
|
||||||
|
}
|
||||||
|
document.getElementById("snapshot-images").appendChild(div);
|
||||||
|
paths.push(data);
|
||||||
}
|
}
|
||||||
function handleShareButtons(shareMsg) {
|
function handleShareButtons(shareMsg) {
|
||||||
var openFeed = document.getElementById('openFeed');
|
var openFeed = document.getElementById('openFeed');
|
||||||
|
|
Loading…
Reference in a new issue