app: gimp_view_render_temp_buf_to_surface(): fix component extraction

The code was still assuming that GimpTempBuf is always 8 bit. Fixed
that, and optimized it to call babl_process() once per line instead of
per pixel. Fixes #13253.
This commit is contained in:
Michael Natterer 2025-06-01 02:57:00 +02:00
parent 7121109655
commit 6151deaff9

View file

@ -1402,28 +1402,23 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
dest += y * dest_stride + x * 4; dest += y * dest_stride + x * 4;
fish = babl_fish (temp_buf_format, fish = babl_fish (temp_buf_format,
babl_format ("cairo-RGB24")); babl_format ("R~G~B~ u8"));
for (i = y; i < (y + height); i++) for (i = 0; i < height; i++)
{ {
const guchar *s = src; guchar line[width * 3];
guchar *d = dest; const guchar *s = line;
guint32 *d = (guint32*) dest;
gint j; gint j;
for (j = x; j < (x + width); j++, d += 4, s += bytes) babl_process (fish, src, line, width);
{
if (bytes > 2)
{
guchar pixel[4] = { s[channel], s[channel], s[channel], 255 };
babl_process (fish, pixel, d, 1); for (j = 0; j < width; j++)
}
else
{ {
guchar pixel[2] = { s[channel], 255 }; *d = s[channel] | s[channel] << 8 | s[channel] << 16;
babl_process (fish, pixel, d, 1); s += 3;
} d += 1;
} }
src += rowstride; src += rowstride;