Initial revision

This commit is contained in:
Arturo Espinosa 1999-01-04 23:53:12 +00:00
parent c20ce75179
commit 249f6c5326
6 changed files with 163 additions and 0 deletions

7
gdk-pixbuf/Makefile.am Normal file
View File

@ -0,0 +1,7 @@
_SOURCES = \
gdk-pixbuf.c \
gdk-pixbuf-io.c
_HEADERS = \
gdk-pixbuf.h

View File

@ -0,0 +1,15 @@
#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

View File

@ -0,0 +1,69 @@
/*
* 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;
}

36
gdk-pixbuf/gdk-pixbuf.c Normal file
View File

@ -0,0 +1,36 @@
/*
* 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);
}

18
gdk-pixbuf/gdk-pixbuf.h Normal file
View File

@ -0,0 +1,18 @@
#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_ */

18
gdk-pixbuf/pixbuf.h Normal file
View File

@ -0,0 +1,18 @@
#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_ */