Skip to content

Commit ca2796a

Browse files
committed
fix low-bitdepth spng save
There was a missing shift, thanks jeffska See #2985
1 parent 29e80ca commit ca2796a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- fix libpng fallback when spng is disabled in meson
55
- add "unlimited" to jpegload
66
- better 0 detection in unpremultiply
7+
- fix low bitdepth spng save [jeffska]
78

89
21/11/21 started 8.13
910
- configure fails for requested but unmet dependencies [remicollet]

libvips/foreign/spngsave.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,15 @@ vips_foreign_save_spng_pack( VipsForeignSaveSpng *spng,
270270
VipsPel *q, VipsPel *p, size_t n )
271271
{
272272
int pixel_mask = 8 / spng->bitdepth - 1;
273+
int shift = 8 - spng->bitdepth;
273274

274275
VipsPel bits;
275276
size_t x;
276277

277278
bits = 0;
278279
for( x = 0; x < n; x++ ) {
279280
bits <<= spng->bitdepth;
280-
bits |= p[x];
281+
bits |= p[x] >> shift;
281282

282283
if( (x & pixel_mask) == pixel_mask )
283284
*q++ = bits;

0 commit comments

Comments
 (0)