Commit 249f6c53 authored by Arturo Espinosa's avatar Arturo Espinosa
Browse files

Initial revision

parent c20ce751
_SOURCES = \
gdk-pixbuf.c \
gdk-pixbuf-io.c
_HEADERS = \
gdk-pixbuf.h
#ifndef _GDK_PIXBUF_CACHE_H_
#define _GDK_PIXBUF_CACHE_H_
/* The optional cache interface */
typedef struct {
int dummy;
} GdkPixBufCache;
GdkPixBufCache *gdk_pixbuf_cache_new (long image_cache_limit,
long pixmap_bitmap_cache_limit);
void gdk_pixbuf_cache_destroy (GdkPixBufCache *cache);
GdkPixBuf *gdk_pixbuf_cache_load_image (GdkPixBufCache *cache,
const char *file);
#endif
/*
* gdk-pixbuf-io.c: Code to load images into GdkPixBufs
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*/
#include <config.h>
#include "gdk-pixbuf.h"
static struct {
char *module_name;
gboolean (*format_check)(char *buffer, int size);
GdkPixBuf *(*load)(char *filename);
int (*save)(char *filename, ...);
} loaders [] = {
{ "png", pixbuf_check_png, NULL, NULL },
{ "jpeg", pixbuf_check_jpeg, NULL, NULL },
{ "tiff", pixbuf_check_tiff, NULL, NULL },
{ "gif", pixbuf_check_gif, NULL, NULL },
{ "xpm", pixbuf_check_xpm, pixbuf_xpm_load, pixbuf_xpm_save },
{ "bmp", pixbuf_check_bmp, NULL, NULL },
{ "ppm", pixbuf_check_ppm, NULL, NULL },
{ NULL, NULL, NULL, NULL },
};
static int
image_file_format (const char *file)
{
FILE *f = fopen (file);
if (!f)
return -1;
}
static void
image_loader_load (int idx)
{
}
GdkPixBuf *
gdk_pixbuf_load_image (const char *file)
{
GdkPixBuf *pixbuf;
FormatLoader format_loader;
FILE *f;
char buffer [128];
f = fopen (file);
if (!f)
return NULL;
n = fread (&buffer, 1, sizeof (buffer), f);
fclose (f);
if (n == 0)
return NULL;
for (i = 0; loaders [i].module_name; i++){
if ((*loaders [i].format_check)(buffer, n)){
if (!loaders [i].load)
image_loader_load (i);
if (!loaders [i].load)
return NULL;
return (*loaders [i].load)(file);
}
}
return NULL;
}
/*
* gdk-pixbuf.c: Resource management.
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*/
#include <config.h>
#include "gdk-pixbuf.h"
static void
gdk_pixbuf_destroy (GdkPixBuf *pixbuf)
{
art_pixbuf_free (pixbuf->art_pixbuf);
g_free (pixbuf);
}
void
gdk_pixbuf_ref (GdkPixBuf *pixbuf)
{
g_return_if_fail (pixbuf != NULL);
pixbuf->ref_count++;
}
void
gdk_pixbuf_unref (GdkPixBuf *pixbuf)
{
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->ref_count == 0);
pixbuf->ref_count--;
if (pixbuf->ref_count)
gdk_pixbuf_destroy (pixbuf);
}
#ifndef _GDK_PIXBUF_H_
#define _GDK_PIXBUF_H_
#include <libart_lgpl/art_pixbuf.h>
typedef struct {
int ref_count;
ArtPixBuf *art_pixbuf;
void (*unref_func)(void *gdkpixbuf);
} GdkPixBuf;
GdkPixBuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
void gdk_pixbuf_ref (GdkPixBuf *pixbuf);
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
GdkPixBuf gdk_pixbuf_duplicate (GdkPixBuf *pixbuf);
#endif /* _GDK_PIXBUF_H_ */
#ifndef _GDK_PIXBUF_H_
#define _GDK_PIXBUF_H_
#include <libart_lgpl/art_pixbuf.h>
typedef struct {
int ref_count;
ArtPixBuf *pixbuf;
void (*unref_func)(void *gdkpixbuf);
} GdkPixBuf;
GdkPixBuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
void gdk_pixbuf_ref (GdkPixBuf *pixbuf);
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
GdkPixBuf gdk_pixbuf_duplicate (GdkPixBuf *pixbuf);
#endif /* _GDK_PIXBUF_H_ */
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