Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to flip image on encode #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion spng/spng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions spng/spng.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down