Example #1
0
/* set the pixel color at (x, y) */
void
set_pixel_color(rgba * pixel_color, texture_info * tex, int x, int y)
{
    float * tex_data;

    /* should pixel be drawn ? */
    if (x > (tex->width - 1) || x < 0 || y > (tex->height - 1) || y < 0)
        return;

    /* if not a color then do not draw */
    if(not_a_color(*pixel_color))
        return;

    tex_data = get_pixel_data(tex, x, y);

    /* set the pixel color */
    tex_data[red] = pixel_color->red;
    tex_data[green] = pixel_color->green;
    tex_data[blue] = pixel_color->blue;
    tex_data[alpha] = pixel_color->alpha;
}
Example #2
0
static guchar *
itdb_thumb_get_rgb_data (Itdb_Device *device, Itdb_Thumb_Ipod_Item *item)
{
#if 0
    #include <unistd.h>
    #include <fcntl.h>
    static gint i=0;
    int fd;
    gchar *name;
#endif
	void *pixels_raw;
	guchar *pixels=NULL;

	g_return_val_if_fail (device, NULL);
	g_return_val_if_fail (item, NULL);
	g_return_val_if_fail (item->size != 0, NULL);

        if (item->format == NULL) {
            return NULL;
        }

	pixels_raw = get_pixel_data (device, item);

#if 0
    name = g_strdup_printf ("thumb_%03d.raw", i++);
    fd = creat (name, S_IRWXU|S_IRWXG|S_IRWXO);
    write (fd, pixels_raw, thumb->size);
    close (fd);
    g_free (name);
#endif
	if (pixels_raw == NULL) {
		return NULL;
	}

	switch (item->format->format)
	{
	case THUMB_FORMAT_RGB565_LE_90:
	case THUMB_FORMAT_RGB565_BE_90:
	    /* FIXME: actually the previous two might require
	       different treatment (used on iPod Photo for the full
	       screen photo thumbnail) */
	case THUMB_FORMAT_RGB565_LE:
	case THUMB_FORMAT_RGB565_BE:
	    pixels = unpack_RGB_565 (pixels_raw, item->size,
				     itdb_thumb_get_byteorder (item->format->format));
	    break;
	case THUMB_FORMAT_RGB555_LE_90:
	case THUMB_FORMAT_RGB555_BE_90:
	    /* FIXME: actually the previous two might require
	       different treatment (used on iPod Photo for the full
	       screen photo thumbnail) */
	case THUMB_FORMAT_RGB555_LE:
	case THUMB_FORMAT_RGB555_BE:
	    pixels = unpack_RGB_555 (pixels_raw, item->size,
				     itdb_thumb_get_byteorder (item->format->format));
	    break;
	case THUMB_FORMAT_RGB888_LE_90:
	case THUMB_FORMAT_RGB888_BE_90:
	    /* FIXME: actually the previous two might require
	       different treatment */
	case THUMB_FORMAT_RGB888_LE:
	case THUMB_FORMAT_RGB888_BE:
	    pixels = unpack_RGB_888 (pixels_raw, item->size,
				     itdb_thumb_get_byteorder (item->format->format));
	    break;
	case THUMB_FORMAT_REC_RGB555_LE_90:
	case THUMB_FORMAT_REC_RGB555_BE_90:
	    /* FIXME: actually the previous two might require
	       different treatment (used on iPod Photo for the full
	       screen photo thumbnail) */
	case THUMB_FORMAT_REC_RGB555_LE:
	case THUMB_FORMAT_REC_RGB555_BE:
	    pixels = unpack_rec_RGB_555 (pixels_raw, item->size,
					 itdb_thumb_get_byteorder (item->format->format),
					 item->format->width, item->format->height);
	    break;
	case THUMB_FORMAT_EXPERIMENTAL_LE:
	case THUMB_FORMAT_EXPERIMENTAL_BE:
#if DEBUG_ARTWORK
	    pixels = unpack_experimental (pixels_raw, item->size,
					  itdb_thumb_get_byteorder (item->format->format),
					  item->format->width, item->format->height);
	    break;
#endif
	case THUMB_FORMAT_UYVY_LE:
	case THUMB_FORMAT_UYVY_BE:
	    pixels = unpack_UYVY (pixels_raw, item->size,
				  itdb_thumb_get_byteorder (item->format->format),
				  item->format->width, item->format->height);
	    break;
	case THUMB_FORMAT_I420_LE:
	case THUMB_FORMAT_I420_BE:
	    pixels = unpack_I420 (pixels_raw, item->size,
				  itdb_thumb_get_byteorder (item->format->format),
				  item->format->width, item->format->height);
	    break;
	}
	g_free (pixels_raw);

	return pixels;

}