Skip to content

Commit

Permalink
Fix .pti compression assuming data length included the header, which …
Browse files Browse the repository at this point in the history
…it doesn't
  • Loading branch information
jacob1 committed Dec 16, 2024
1 parent cc37da1 commit 3dbc6c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/graphics/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ std::unique_ptr<std::vector<char>> Graphics::ptif_pack(PlaneAdapter<std::vector<
unsigned char *red_chan = (unsigned char*)calloc(1, w*h);
unsigned char *green_chan = (unsigned char*)calloc(1, w*h);
unsigned char *blue_chan = (unsigned char*)calloc(1, w*h);
unsigned char *data = (unsigned char*)malloc(((w*h)*3)+8);
unsigned char *data = (unsigned char*)malloc(((w*h)*3));

for (int cx = 0; cx < w; cx++)
{
Expand Down Expand Up @@ -213,7 +213,7 @@ std::unique_ptr<std::vector<char>> Graphics::ptif_pack(PlaneAdapter<std::vector<
header[7] = h>>8;

std::vector<char> result;
if (BZ2WCompress(result, (char *)data, ((w*h)*3)+8, ((w*h)*3)+8) != BZ2WCompressOk)
if (BZ2WCompress(result, (char *)data, (w*h)*3, (w*h)*3) != BZ2WCompressOk)
{
free(data);
delete[] header;
Expand Down

0 comments on commit 3dbc6c4

Please sign in to comment.