Commit c84e8433 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

added missing code for grayscale previews.

2004-07-23  Sven Neumann  <sven@gimp.org>

	* libgimp/gimppixbuf.c (gimp_pixbuf_from_data): added missing code
	for grayscale previews.
parent 333489a6
2004-07-23 Sven Neumann <sven@gimp.org>
* libgimp/gimppixbuf.c (gimp_pixbuf_from_data): added missing code
for grayscale previews.
2004-07-23 Sven Neumann <sven@gimp.org>
* app/core/gimpgradient-load.c (svg_parser_end_element): fixed
......
......@@ -75,8 +75,8 @@ gimp_image_get_thumbnail (gint32 image_ID,
NULL);
return gimp_pixbuf_from_data (data,
thumb_width, thumb_height, thumb_bpp,
alpha);
thumb_width, thumb_height, thumb_bpp,
alpha);
}
/**
......@@ -131,12 +131,73 @@ gimp_pixbuf_from_data (guchar *data,
{
GdkPixbuf *pixbuf;
g_return_val_if_fail (bpp == 3 || bpp == 4, NULL);
pixbuf = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB, (bpp == 4), 8,
width, height, width * bpp,
(GdkPixbufDestroyNotify) g_free, NULL);
switch (bpp)
{
case 1:
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height);
{
guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
gint rowstride = gdk_pixbuf_get_rowstride (pixbuf);
gint y;
for (y = 0; y < height; y++)
{
guchar *dest = pixels;
gint x;
for (x = 0; x < width; x++, data += 1, dest += 3)
{
dest[0] = dest[1] = dest[2] = data[0];
}
pixels += rowstride;
}
}
bpp = 3;
break;
case 2:
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
{
guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
gint rowstride = gdk_pixbuf_get_rowstride (pixbuf);
gint y;
for (y = 0; y < height; y++)
{
guchar *dest = pixels;
gint x;
for (x = 0; x < width; x++, data += 2, dest += 4)
{
dest[0] = dest[1] = dest[2] = data[0];
dest[3] = data[1];
}
pixels += rowstride;
}
}
bpp = 4;
break;
case 3:
pixbuf = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB, FALSE, 8,
width, height, width * bpp,
(GdkPixbufDestroyNotify) g_free, NULL);
break;
case 4:
pixbuf = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB, TRUE, 8,
width, height, width * bpp,
(GdkPixbufDestroyNotify) g_free, NULL);
break;
default:
g_return_val_if_reached (NULL);
return NULL;
}
if (bpp == 4)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment