FS#13718 - The image_save library (rocklua) can't correctly save an image with an odd resolution.
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 530cad0c7a1bdae416d5bc5ae15392951bc2a7e2 Author: William Wilgus <[email protected]> Date: Tue Jan 20 22:49:24 2026 -0500 FS#13718 - The image_save library (rocklua) can't correctly save an image with an odd resolution. the image save script apparently does not like odd numbers for width local bytesleft = linebytes - (bytesperpixel * w ) this should actually be pxleft since the image loop below returns pixels not bytes tested on 1 bit 2 bit, 16 bit and 32 bit images in sim Change-Id: Ic186c095c29d318dcfb7d76b83e07c75f1460584 diff --git a/apps/plugins/lua/include_lua/image_save.lua b/apps/plugins/lua/include_lua/image_save.lua index 27e63ca65a..df88e9ba91 100644 --- a/apps/plugins/lua/include_lua/image_save.lua +++ b/apps/plugins/lua/include_lua/image_save.lua @@ -188,8 +188,9 @@ do for i=1, #fbuffer do fbuffer[i] = _NIL end -- reuse table local imgdata = fbuffer - -- pad rows to a multiple of 4 bytes - local bytesleft = linebytes - (bytesperpixel * w) + -- pad rows to get even number of pixels + local pxleft = (linebytes - (bytesperpixel * w)) / bytesperpixel + local t_data = {} local fs_bytes_E = s_bytesLE -- default save in Little Endian @@ -198,7 +199,7 @@ do end -- Bitmap lines start at bottom unless biHeight is negative - for point in _points(img, 1, h, w + bytesleft, 1, 1, 1, true) do + for point in _points(img, 1, h, w + pxleft, 1, 1, 1, true) do imgdata[#imgdata + 1] = fs_bytes_E(bpp, point or 0) if #fbuffer >= 31 then -- buffered write, increase # for performance -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs