1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* gdk-pixbuf-data.c: Code to load images into GdkPixbufs from constant data
*
* Author:
* Michael Fulbright (drmike@redhat.com)
* Copyright (C) 1999 Red Hat, Inc.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include "gdk-pixbuf.h"
/* This function does all the work. */
static GdkPixbuf *
_pixbuf_create_from_rgb_d(unsigned char *data, int w, int h)
{
GdkPixbuf *pixbuf;
ArtPixBuf *art_pixbuf;
art_u8 *pixels;
pixels = art_alloc (w*h*3);
if (!pixels) {
g_warning ("RGBD: Cannot alloc ArtBuf");
return NULL;
}
memcpy (pixels, data, w*h*3);
art_pixbuf = art_pixbuf_new_rgb (pixels, w, h, (w*3));
pixbuf = gdk_pixbuf_new (art_pixbuf, NULL);
if (!pixbuf)
art_free (pixels);
return pixbuf;
}
GdkPixbuf *
gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, int rgb_width, int rgb_height)
{
g_return_val_if_fail (data != NULL, NULL);
return _pixbuf_create_from_rgb_d(data, rgb_width, rgb_height);
}
|