minor fix.
This commit is contained in:
@@ -240,7 +240,7 @@ Taking care of proper referencing
|
||||
---------------------------------
|
||||
|
||||
There are some cases where referencing of widgets from outside the toolkit
|
||||
(on the application side is needed).
|
||||
(on the application side) is needed.
|
||||
Once the application performes an operation on a widget that will cause
|
||||
its reference count to drop, if it wants to take further actions on the
|
||||
widget, it needs to hold a reference to it.
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
lib_LTLIBRARIES = \
|
||||
libgdk-pixbuf.la \
|
||||
libpixbuf-png.la
|
||||
|
||||
#
|
||||
# The GdkPixBuf library
|
||||
#
|
||||
libgdk_pixbufincludedir = $(includedir)/gdk-pixbuf
|
||||
|
||||
libgdk_pixbuf_la_SOURCES = \
|
||||
gdk-pixbuf.c \
|
||||
gdk-pixbuf-io.c
|
||||
|
||||
libgdk_pixbufinclude_HEADERS = \
|
||||
gdk-pixbuf.h
|
||||
|
||||
#
|
||||
# The PNG plugin.
|
||||
#
|
||||
libpixbuf_png_la_SOURCES = \
|
||||
io-png.c
|
||||
@@ -1,15 +0,0 @@
|
||||
#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
|
||||
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* gdk-pixbuf-io.c: Code to load images into GdkPixBufs
|
||||
*
|
||||
* Author:
|
||||
* Miguel de Icaza (miguel@gnu.org)
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include "gdk-pixbuf.h"
|
||||
|
||||
static gboolean
|
||||
pixbuf_check_png (unsigned char *buffer, int size)
|
||||
{
|
||||
if (size < 28)
|
||||
return FALSE;
|
||||
|
||||
if (buffer [0] != 0x89 ||
|
||||
buffer [1] != 'P' ||
|
||||
buffer [2] != 'N' ||
|
||||
buffer [3] != 'G' ||
|
||||
buffer [4] != 0x0d ||
|
||||
buffer [5] != 0x0a ||
|
||||
buffer [6] != 0x1a ||
|
||||
buffer [7] != 0x0a)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pixbuf_check_jpeg (unsigned char *buffer, int size)
|
||||
{
|
||||
if (size < 10)
|
||||
return FALSE;
|
||||
|
||||
if (buffer [0] != 0xff || buffer [1] != 0xd8)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pixbuf_check_tiff (unsigned char *buffer, int size)
|
||||
{
|
||||
if (size < 10)
|
||||
return FALSE;
|
||||
|
||||
if (buffer [0] == 'M' && buffer [1] == 'M' && buffer [2] == 0 && buffer [3] == 0x2a)
|
||||
return TRUE;
|
||||
|
||||
if (buffer [0] == 'I' && buffer [1] == 'I' && buffer [2] == 0x2a && buffer [3] == 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pixbuf_check_gif (unsigned char *buffer, int size)
|
||||
{
|
||||
if (size < 20)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (buffer, "GIF8", 4) == 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pixbuf_check_xpm (unsigned char *buffer, int size)
|
||||
{
|
||||
if (size < 20)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (buffer, "/* XPM */", 9) == 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pixbuf_check_bmp (unsigned char *buffer, int size)
|
||||
{
|
||||
if (size < 20)
|
||||
return FALSE;
|
||||
|
||||
if (buffer [0] != 'B' || buffer [1] != 'M')
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pixbuf_check_ppm (unsigned char *buffer, int size)
|
||||
{
|
||||
if (size < 20)
|
||||
return FALSE;
|
||||
|
||||
if (buffer [0] == 'P'){
|
||||
if (buffer [1] == '1' ||
|
||||
buffer [1] == '2' ||
|
||||
buffer [1] == '3' ||
|
||||
buffer [1] == '4' ||
|
||||
buffer [1] == '5' ||
|
||||
buffer [1] == '6')
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static struct {
|
||||
char *module_name;
|
||||
gboolean (*format_check)(unsigned char *buffer, int size);
|
||||
GModule *module;
|
||||
GdkPixBuf *(*load)(FILE *f)
|
||||
int (*save)(char *filename, ...);
|
||||
} file_formats [] = {
|
||||
{ "png", pixbuf_check_png, NULL, NULL, NULL },
|
||||
{ "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL },
|
||||
{ "tiff", pixbuf_check_tiff, NULL, NULL, NULL },
|
||||
{ "gif", pixbuf_check_gif, NULL, NULL, NULL },
|
||||
{ "xpm", pixbuf_check_xpm, NULL, NULL, NULL }
|
||||
{ "bmp", pixbuf_check_bmp, NULL, NULL, NULL },
|
||||
{ "ppm", pixbuf_check_ppm, NULL, NULL, 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_handler_load (int idx)
|
||||
{
|
||||
char *module_name = g_strconcat ("pixbuf-", file_formats [idx].module_name, NULL);
|
||||
char *path;
|
||||
GModule *module;
|
||||
void *load_sym, *save_sym;
|
||||
|
||||
path = g_module_build_path (PIXBUF_LIBDIR, module_name);
|
||||
g_free (module_name);
|
||||
|
||||
module = g_module_open (path, G_MODULE_BIND_LAZY);
|
||||
if (!module)
|
||||
return;
|
||||
|
||||
file_formats [idx].module = module;
|
||||
|
||||
if (g_module_symbol (module, "image_load", &load_sym))
|
||||
file_formats [idx].load = load_sym;
|
||||
|
||||
if (g_module_symbol (module, "image_save", &save_sym))
|
||||
file_formats [idx].save = save_sym;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (n == 0){
|
||||
fclose (f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; file_formats [i].module_name; i++){
|
||||
if ((*file_formats [i].format_check)(buffer, n)){
|
||||
if (!file_formats [i].load)
|
||||
image_handler_load (i);
|
||||
|
||||
if (!file_formats [i].load){
|
||||
fclose (f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rewind (f);
|
||||
pixbuf = (*file_formats [i].load)(f);
|
||||
fclose (f);
|
||||
return pixbuf;
|
||||
}
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef _GDK_PIXBUF_H_
|
||||
#define _GDK_PIXBUF_H_
|
||||
|
||||
#include <libart_lgpl/art_misc.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_ */
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* io-png.c: GdkPixBuf image loader for PNG files.
|
||||
*
|
||||
* Author:
|
||||
* Miguel de Icaza (miguel@gnu.org)
|
||||
*
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include "gdk-pixbuf.h"
|
||||
#include "gdk-pixbuf-io.h"
|
||||
#include <png.h>
|
||||
|
||||
/* Shared library entry point */
|
||||
GdkPixBuf *
|
||||
image_load (FILE *f);
|
||||
{
|
||||
png_structp png;
|
||||
png_infop info_ptr, end_info;
|
||||
int width, height, depth, color_type, interlace_type;
|
||||
int have_alpha, number_passes;
|
||||
art_u8 *data;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (png)
|
||||
return NULL;
|
||||
|
||||
info_ptr = png_create_info_struct (png);
|
||||
if (!info_ptr){
|
||||
png_destroy_read_struct (&png, NULL, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
end_info = png_create_info_struct (png);
|
||||
if (!end_info){
|
||||
png_destroy_read_struct (&png, &info_ptr, NULL);
|
||||
return NULL:
|
||||
}
|
||||
|
||||
if (setjmp (png->jmpbuf)){
|
||||
png_destroy_read_struct (&png, &info_ptr, &end_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
png_init_io (pngptr, f);
|
||||
|
||||
png_read_info (png, info_ptr);
|
||||
png_get_IHDR (png, info_ptr, &width, &height, &depth, &color_type, &interlace_type, NULL, NULL);
|
||||
|
||||
if (color_type == color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand (png);
|
||||
|
||||
/*
|
||||
* Strip 16 bit information to 8 bit
|
||||
*/
|
||||
png_set_strip_16 (png);
|
||||
|
||||
/*
|
||||
* Extract multiple pixels with bit depths 1, 2 and 4 from a single
|
||||
* byte into separate bytes
|
||||
*/
|
||||
png_set_packing (png);
|
||||
|
||||
/*
|
||||
* Makes the PNG file to be rendered into RGB or RGBA
|
||||
* modes (no matter of the bit depth nor the image
|
||||
* mode
|
||||
*/
|
||||
png_set_expand (png);
|
||||
|
||||
/*
|
||||
* Simplify loading by always having 4 bytes
|
||||
*/
|
||||
png_set_filler (png, 0xff, PNG_FILLER_AFTER);
|
||||
|
||||
if (color_type & PNG_COLOR_MASK_ALPHA)
|
||||
have_alpha = 1
|
||||
else
|
||||
have_alpha = 0;
|
||||
|
||||
data = art_alloc (width * height * (3 + have_alpha));
|
||||
if (!data){
|
||||
png_destroy_read_struct (&png, &info_ptr, &end_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
number_passes = png_set_interlace_handling (png);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#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_ */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user