View | Details | Raw Unified | Return to bug 129642
Collapse All | Expand All

(-)gdk-pixbuf-0.22.0/gdk-pixbuf/io-xpm.c (-18 / +6 lines)
Lines 323-335 mem_buffer (enum buf_op op, gpointer han Link Here
323
	return NULL;
323
	return NULL;
324
}
324
}
325
325
326
/* Destroy notification function for the pixbuf */
327
static void
328
free_buffer (guchar *pixels, gpointer data)
329
{
330
	free (pixels);
331
}
332
333
static gboolean
326
static gboolean
334
xpm_color_parse (const char *spec, XColor *color)
327
xpm_color_parse (const char *spec, XColor *color)
335
{
328
{
Lines 348-354 pixbuf_create_from_xpm (const gchar * (* Link Here
348
	gchar pixel_str[32];
341
	gchar pixel_str[32];
349
	GHashTable *color_hash;
342
	GHashTable *color_hash;
350
	_XPMColor *colors, *color, *fallbackcolor;
343
	_XPMColor *colors, *color, *fallbackcolor;
351
	guchar *pixels, *pixtmp;
344
	guchar *pixtmp;
345
	GdkPixbuf* pixbuf;
352
346
353
	fallbackcolor = NULL;
347
	fallbackcolor = NULL;
354
348
Lines 418-429 pixbuf_create_from_xpm (const gchar * (* Link Here
418
			fallbackcolor = color;
412
			fallbackcolor = color;
419
	}
413
	}
420
414
421
	if (is_trans)
415
	pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, is_trans, 8, w, h);
422
		pixels = malloc (w * h * 4);
416
	if (!pixbuf) {
423
	else
424
		pixels = malloc (w * h * 3);
425
426
	if (!pixels) {
427
		g_hash_table_destroy (color_hash);
417
		g_hash_table_destroy (color_hash);
428
		g_free (colors);
418
		g_free (colors);
429
		g_free (name_buf);
419
		g_free (name_buf);
Lines 431-437 pixbuf_create_from_xpm (const gchar * (* Link Here
431
	}
421
	}
432
422
433
	wbytes = w * cpp;
423
	wbytes = w * cpp;
434
	pixtmp = pixels;
424
	pixtmp = pixbuf->pixels;
435
425
436
	for (ycnt = 0; ycnt < h; ycnt++) {
426
	for (ycnt = 0; ycnt < h; ycnt++) {
437
		buffer = (*get_buf) (op_body, handle);
427
		buffer = (*get_buf) (op_body, handle);
Lines 464-472 pixbuf_create_from_xpm (const gchar * (* Link Here
464
	g_free (colors);
454
	g_free (colors);
465
	g_free (name_buf);
455
	g_free (name_buf);
466
456
467
	return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, is_trans, 8,
457
	return pixbuf;
468
					 w, h, is_trans ? (w * 4) : (w * 3),
469
					 free_buffer, NULL);
470
}
458
}
471
459
472
/* Shared library entry point for file loading */
460
/* Shared library entry point for file loading */

Return to bug 129642