Massive update...
gdk-pixbuf-io.c: Fixed to compile and run in a very crippled state.
io-bpm.c: Rough start on a WIN/OS2 BMP loader
testpixbuf.c: Really crude test program for gdk-pixbuf
io-gif.c: Fixed some boneheaded uninitalized variables causing the
loader to choke
--- /dev/null
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+
+/* Note: these #includes differ slightly from the testrgb.c file included
+ in the GdkRgb release. */
+
+/* For gettimeofday */
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <gtk/gtk.h>
+#include "gdk-pixbuf.h"
+
+static void
+quit_func (GtkWidget *widget, gpointer dummy)
+{
+ gtk_main_quit ();
+}
+
+static void
+testrgb_rgb_test (GtkWidget *drawing_area, GdkPixBuf *pixbuf)
+{
+ guchar *buf;
+ gint i, j;
+ gint offset;
+ guchar val;
+ gdouble start_time, total_time;
+ gint x, y;
+ gboolean dither;
+ int dith_max;
+
+ buf = pixbuf->art_pixbuf->pixels;
+ x = pixbuf->art_pixbuf->width;
+ y = pixbuf->art_pixbuf->height;
+
+ g_print("X: %d Y: %d\n", x, y);
+while (TRUE) {
+ if (pixbuf->art_pixbuf->has_alpha){
+g_print("32\n");
+ gdk_draw_rgb_32_image (drawing_area->window,
+ drawing_area->style->black_gc,
+ 0, 0, x, y,
+ GDK_RGB_DITHER_MAX,
+ pixbuf->art_pixbuf->pixels,
+ pixbuf->art_pixbuf->rowstride);
+}else{
+g_print("24\n");
+ gdk_draw_rgb_image (drawing_area->window,
+ drawing_area->style->white_gc,
+ 0, 0, x, y,
+ GDK_RGB_DITHER_NORMAL,
+ buf,
+ pixbuf->art_pixbuf->rowstride);
+}}
+
+}
+
+void
+new_testrgb_window (GdkPixBuf *pixbuf)
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *button;
+ GtkWidget *drawing_area;
+ gint w, h;
+
+ w = pixbuf->art_pixbuf->width;
+ h = pixbuf->art_pixbuf->height;
+
+ window = gtk_widget_new (gtk_window_get_type (),
+ "GtkObject::user_data", NULL,
+ "GtkWindow::type", GTK_WINDOW_TOPLEVEL,
+ "GtkWindow::title", "testrgb",
+ "GtkWindow::allow_shrink", FALSE,
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (window), "destroy",
+ (GtkSignalFunc) quit_func, NULL);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+
+ drawing_area = gtk_drawing_area_new ();
+
+ gtk_widget_set_usize (drawing_area, w, h);
+ gtk_box_pack_start (GTK_BOX (vbox), drawing_area, FALSE, FALSE, 0);
+ gtk_widget_show (drawing_area);
+
+ button = gtk_button_new_with_label ("Quit");
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) gtk_widget_destroy,
+ GTK_OBJECT (window));
+
+ gtk_widget_show (button);
+
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+ gtk_widget_show (vbox);
+
+ gtk_widget_show (window);
+
+
+ testrgb_rgb_test (drawing_area, pixbuf);
+}
+
+int
+main (int argc, char **argv)
+{
+ GdkPixBuf *pixbuf;
+
+ gtk_init (&argc, &argv);
+
+ gdk_rgb_set_verbose (TRUE);
+
+ gdk_rgb_init ();
+
+ gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
+ gtk_widget_set_default_visual (gdk_rgb_get_visual ());
+ pixbuf = gdk_pixbuf_load_image ("test.gif");
+ new_testrgb_window (pixbuf);
+
+ gtk_main ();
+
+ return 0;
+}
Makefile.in
Makefile
+.deps
+.xvpics
libpixbuf-xpm.la \
libpixbuf-tiff.la
+noinst_PROGRAMS = testpixbuf
+DEPS = libgdk-pixbuf.la
+LDADDS = libgdk-pixbuf.la @GNOME_LIBDIR@ @GNOMEUI_LIBS@
+
+testpixbuf_DEPENDENCIES = $(DEPS)
+testpixbuf_LDADD = $(LDADDS)
+testpixbuf_CFLAGS = $(GNOME_INCLUDEDIR)
+
#
# The GdkPixBuf library
#
-libgdk_pixbufincludedir = $(includedir)/gdk-pixbuf
+libgdk_pixbufincludedir = $(includedir)/gdk-pixbuf $(GNOME_INCLUDEDIR)
libgdk_pixbuf_la_SOURCES = \
gdk-pixbuf.c \
#
libpixbuf_png_la_SOURCES = \
io-png.c
+libpixbuf_png_la_LDFLAGS = -avoid-version
+libpixbuf_png_la_LIBADD = -lpng -lz
#
# The JPEG loader
#
libpixbuf_jpeg_la_SOURCES = \
io-jpeg.c
+libpixbuf_jpeg_la_LDFLAGS = -avoid-version
+libpixbuf_jpeg_la_LIBADD = -ljpeg
#
# The XPM loader
#
libpixbuf_gif_la_SOURCES = \
io-gif.c
+libpixbuf_gif_la_LDFLAGS = -avoid-version
+libpixbuf_gif_la_LIBADD= -lungif
#
# The TIFF loader
#
-libpixbuf_gif_la_SOURCES= \
+libpixbuf_tiff_la_SOURCES= \
io-tiff.c
*/
#include <config.h>
#include <stdio.h>
+#include <glib.h>
+#include <gmodule.h>
#include "gdk-pixbuf.h"
+#define PIXBUF_LIBDIR "."
+
static gboolean
pixbuf_check_png (unsigned char *buffer, int size)
{
char *module_name;
gboolean (*format_check)(unsigned char *buffer, int size);
GModule *module;
- GdkPixBuf *(*load)(FILE *f)
+ 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 },
+ { "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);
+ FILE *f = fopen (file, "r");
if (!f)
return -1;
gdk_pixbuf_load_image (const char *file)
{
GdkPixBuf *pixbuf;
- FormatLoader format_loader;
+ gint n, i;
FILE *f;
char buffer [128];
- f = fopen (file);
+ f = fopen (file, "r");
if (!f)
return NULL;
n = fread (&buffer, 1, sizeof (buffer), f);
return NULL;
}
- rewind (f);
+ fseek(f, 0, SEEK_SET);
pixbuf = (*file_formats [i].load)(f);
fclose (f);
return pixbuf;
--- /dev/null
+/* Nothing here yet */
* Miguel de Icaza (miguel@gnu.org)
*/
#include <config.h>
+#include <glib.h>
#include "gdk-pixbuf.h"
--- /dev/null
+/*
+ * io-bmp.c: GdkPixBuf I/O for BMP files.
+ *
+ * Copyright (C) 1999 Mark Crichton
+ * Author: Mark Crichton <crichton@gimp.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <glib.h>
+#include "gdk-pixbuf.h"
+#include "gdk-pixbuf-io.h"
+
+/* Loosely based off the BMP loader from The GIMP */
+
+/* Shared library entry point */
+GdkPixBuf *image_load(FILE * f)
+{
+ GdkPixBuf *pixbuf;
+ art_u8 *pixels;
+
+ /* Ok, now stuff the GdkPixBuf with goodies */
+
+ pixbuf = g_new(GdkPixBuf, 1);
+
+ if (is_trans)
+ pixbuf->art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4));
+ else
+ pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
+
+ /* Ok, I'm anal...shoot me */
+ if (!(pixbuf->art_pixbuf))
+ return NULL;
+ pixbuf->ref_count = 0;
+ pixbuf->unref_func = NULL;
+
+ return pixbuf;
+}
/* Shared library entry point */
GdkPixBuf *image_load(FILE * f)
{
- gint fn, is_trans, done;
+ gint fn, is_trans = FALSE;
+ gint done = 0;
gint t_color = -1;
gint w, h, i, j;
art_u8 *pixels, *tmpptr;
g_return_val_if_fail(f != NULL, NULL);
fn = fileno(f);
+/* lseek(fn, 0, 0);*/
gif = DGifOpenFileHandle(fn);
if (!gif) {
}
w = gif->Image.Width;
h = gif->Image.Height;
- rows = g_malloc(h * sizeof(GifRowType *));
+ rows = g_malloc0(h * sizeof(GifRowType *));
if (!rows) {
DGifCloseFile(gif);
return NULL;
}
for (i = 0; i < h; i++) {
- rows[i] = g_malloc(w * sizeof(GifPixelType));
+ rows[i] = g_malloc0(w * sizeof(GifPixelType));
if (!rows[i]) {
DGifCloseFile(gif);
for (i = 0; i < h; i++)
for (i = 0; i < h; i++)
DGifGetLine(gif, rows[i], w);
}
- done = TRUE;
+ done = 1;
} else if (rec == EXTENSION_RECORD_TYPE) {
gint ext_code;
GifByteType *ext;
DGifGetExtension(gif, &ext_code, &ext);
while (ext) {
- if ((ext_code == GRAPHICS_EXT_FUNC_CODE) &&
+ if ((ext_code == 0xf9) &&
(ext[1] & 1) && (t_color < 0)) {
is_trans = TRUE;
t_color = (gint) ext[4];
tmpptr[3] = 0;
else
tmpptr[3] = 0xFF;
- tmpptr += (is_trans ? 3 : 4);
+ tmpptr += (is_trans ? 4 : 3);
}
}
return pixbuf;
}
+
+image_save() {}
FILE *infile;
gchar *buffer;
guint buffer_size;
-};
+} file_handle;
struct mem_handle {
gchar **data;
int offset;
-};
+} mem_handle;
static gint
xpm_seek_string(FILE * infile,
GdkPixBuf *image_load(FILE * f)
{
GdkPixBuf *pixbuf;
- struct file_handler h;
+ struct file_handle h;
g_return_val_if_fail(f != NULL, NULL);
- h = g_new(file_handler, 1);
h.infile = f;
pixbuf = _pixbuf_create_from_xpm(file_buffer, &h);
- g_free(h);
+ g_free(h.buffer);
return pixbuf;
}