Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Sep 15, 2024
1 parent 0b1941b commit affe9ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
14 changes: 9 additions & 5 deletions nQuantGpp/ApngWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

namespace PngEncode
{
ApngWriter::ApngWriter(const int width, const int height, const long fps, const bool loop)
ApngWriter::ApngWriter(const long fps, const bool loop)
{
_width = width;
_height = height;
_fps = fps;
_loop = loop;
}
Expand Down Expand Up @@ -383,9 +381,12 @@ namespace PngEncode
cout << ss.str().c_str();

if (i > 0) {
auto width = to_uint32_big_endian(&pngList[i][idx + 4]);
auto height = to_uint32_big_endian(&pngList[i][idx + 8]);

// insert the fcTL chunk **after** last IDAT chunk
vector<uchar> fcTL_chunk_bytes;
create_fcTL_chunk(fcTL_chunk_bytes, seq++, _width, _height, _fps);
create_fcTL_chunk(fcTL_chunk_bytes, seq++, width, height, _fps);
auto fcTL_chunk_start_pos = _data.end() - 12;
_data.insert(fcTL_chunk_start_pos, fcTL_chunk_bytes.begin(), fcTL_chunk_bytes.end());

Expand Down Expand Up @@ -414,9 +415,12 @@ namespace PngEncode
++seq;
}
else {
auto width = to_uint32_big_endian(&_data[idx + 4]);
auto height = to_uint32_big_endian(&_data[idx + 8]);

// insert the fcTL chunk **before** first IDAT chunk
vector<uchar> fcTL_chunk_bytes;
create_fcTL_chunk(fcTL_chunk_bytes, seq++, _width, _height, _fps);
create_fcTL_chunk(fcTL_chunk_bytes, seq++, width, height, _fps);
auto fcTL_chunk_start_pos = _data.begin() + next_chunk_start_idx;
_data.insert(fcTL_chunk_start_pos, fcTL_chunk_bytes.begin(), fcTL_chunk_bytes.end());
}
Expand Down
3 changes: 1 addition & 2 deletions nQuantGpp/ApngWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ namespace PngEncode
{
private:
bool _loop;
int _width, _height;
long _fps;
vector<uchar> _data;

public:
ApngWriter(const int width, const int height, const long fps = 30, const bool loop = true);
ApngWriter(const long fps = 30, const bool loop = true);
bool AddImages(vector<vector<uchar> >& pngList);
void Save(const string& destPath);
};
Expand Down
2 changes: 1 addition & 1 deletion nQuantGpp/nQuantGpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ void OutputImages(const fs::path& sourceDir, string& targetDir, const uint& nMax
tcout << "\rWell done!!! " << endl;
}
else {
PngEncode::ApngWriter apng(pSources[0]->rows, pSources[0]->cols);
PngEncode::ApngWriter apng;
apng.AddImages(bytesList);
apng.Save(destPath);
}
Expand Down

0 comments on commit affe9ef

Please sign in to comment.