Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to flip image on encode
Browse files Browse the repository at this point in the history
Francois Nedelec committed Sep 1, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent eb26079 commit 4269c70
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spng/spng.c
Original file line number Diff line number Diff line change
@@ -4863,7 +4863,11 @@ int spng_encode_image(spng_ctx *ctx, const void *img, size_t len, int fmt, int f

do
{
size_t ioffset = ri->row_num * ctx->image_width;
size_t ioffset;
if ( flags & SPNG_ENCODE_FLIP_Y )
ioffset = ( ihdr->height - ri->row_num - 1 ) * ctx->image_width;
else
ioffset = ri->row_num * ctx->image_width;

ret = encode_row(ctx, (unsigned char*)img + ioffset, ctx->image_width);

1 change: 1 addition & 0 deletions spng/spng.h
Original file line number Diff line number Diff line change
@@ -216,6 +216,7 @@ enum spng_encode_flags
{
SPNG_ENCODE_PROGRESSIVE = 1, /* Initialize for progressive writes */
SPNG_ENCODE_FINALIZE = 2, /* Finalize PNG after encoding image */
SPNG_ENCODE_FLIP_Y = 4, /* Flip image vertically */
};

struct spng_ihdr

0 comments on commit 4269c70

Please sign in to comment.