Commit 74268afd authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Arturo Espinosa
Browse files

Reindented to use the GNOME Indentation.

1999-10-18  Federico Mena Quintero  <federico@redhat.com>

	* src/*: Reindented to use the GNOME Indentation.
parent 3b9835b5
This diff is collapsed.
1999-10-18 Federico Mena Quintero <federico@redhat.com>
* src/*: Reindented to use the GNOME Indentation.
1999-10-18 Havoc Pennington <hp@pobox.com> 1999-10-18 Havoc Pennington <hp@pobox.com>
* configure.in: Use AM_PATH_GLIB instead of glib-config directly * configure.in: Use AM_PATH_GLIB instead of glib-config directly
......
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
/* The optional cache interface */ /* The optional cache interface */
typedef struct { typedef struct {
int dummy; int dummy;
} GdkPixBufCache; } GdkPixbufCache;
GdkPixBufCache *gdk_pixbuf_cache_new (long image_cache_limit, GdkPixbufCache *gdk_pixbuf_cache_new (long image_cache_limit,
long pixmap_bitmap_cache_limit); long pixmap_bitmap_cache_limit);
void gdk_pixbuf_cache_destroy (GdkPixBufCache *cache); void gdk_pixbuf_cache_destroy (GdkPixbufCache *cache);
GdkPixBuf *gdk_pixbuf_cache_load_image (GdkPixBufCache *cache, GdkPixbuf *gdk_pixbuf_cache_load_image (GdkPixbufCache *cache,
const char *file); const char *file);
#endif #endif
/* /*
* gdk-pixbuf-data.c: Code to load images into GdkPixBufs from constant data * gdk-pixbuf-data.c: Code to load images into GdkPixbufs from constant data
* *
* Author: * Author:
* Michael Fulbright (drmike@redhat.com) * Michael Fulbright (drmike@redhat.com)
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
/* This function does all the work. */ /* This function does all the work. */
static GdkPixBuf * static GdkPixbuf *
_pixbuf_create_from_rgb_d(unsigned char *data, int w, int h) _pixbuf_create_from_rgb_d(unsigned char *data, int w, int h)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
ArtPixBuf *art_pixbuf; ArtPixBuf *art_pixbuf;
art_u8 *pixels; art_u8 *pixels;
...@@ -40,12 +40,10 @@ _pixbuf_create_from_rgb_d(unsigned char *data, int w, int h) ...@@ -40,12 +40,10 @@ _pixbuf_create_from_rgb_d(unsigned char *data, int w, int h)
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, int rgb_width, int rgb_height)
int rgb_width, int rgb_height)
{ {
g_return_val_if_fail (data != NULL, NULL); g_return_val_if_fail (data != NULL, NULL);
return _pixbuf_create_from_rgb_d(data, rgb_width, rgb_height); return _pixbuf_create_from_rgb_d(data, rgb_width, rgb_height);
} }
...@@ -4,11 +4,7 @@ ...@@ -4,11 +4,7 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk-pixbuf.h> #include <gdk-pixbuf.h>
GdkPixBuf *gdk_pixbuf_rgb_from_drawable (GdkWindow *window, GdkPixbuf *gdk_pixbuf_rgb_from_drawable (GdkWindow *window, gint x, gint y, gint width, gint height);
gint x, gint y, GdkPixbuf *gdk_pixbuf_rgba_from_drawable (GdkWindow *window, gint x, gint y, gint width, gint height);
gint width, gint height);
GdkPixBuf *gdk_pixbuf_rgba_from_drawable (GdkWindow *window,
gint x, gint y,
gint width, gint height);
#endif /* _GDK_PIXBUF_DRAWABLE_H_ */ #endif /* _GDK_PIXBUF_DRAWABLE_H_ */
/* /*
* gdk-pixbuf-io.c: Code to load images into GdkPixBufs * gdk-pixbuf-io.c: Code to load images into GdkPixbufs
* *
* Author: * Author:
* Miguel de Icaza (miguel@gnu.org) * Miguel de Icaza (miguel@gnu.org)
...@@ -106,7 +106,7 @@ pixbuf_check_ppm (unsigned char *buffer, int size) ...@@ -106,7 +106,7 @@ pixbuf_check_ppm (unsigned char *buffer, int size)
if (size < 20) if (size < 20)
return FALSE; return FALSE;
if (buffer [0] == 'P'){ if (buffer [0] == 'P') {
if (buffer [1] == '1' || if (buffer [1] == '1' ||
buffer [1] == '2' || buffer [1] == '2' ||
buffer [1] == '3' || buffer [1] == '3' ||
...@@ -122,8 +122,8 @@ static struct { ...@@ -122,8 +122,8 @@ static struct {
char *module_name; char *module_name;
gboolean (*format_check)(unsigned char *buffer, int size); gboolean (*format_check)(unsigned char *buffer, int size);
GModule *module; GModule *module;
GdkPixBuf *(*load)(FILE *f); GdkPixbuf *(*load)(FILE *f);
int (*save)(GdkPixBuf *p, FILE *f, ...); int (*save)(GdkPixbuf *p, FILE *f, ...);
} file_formats [] = { } file_formats [] = {
{ "png", pixbuf_check_png, NULL, NULL, NULL }, { "png", pixbuf_check_png, NULL, NULL, NULL },
{ "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL }, { "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL },
...@@ -163,10 +163,10 @@ image_handler_load (int idx) ...@@ -163,10 +163,10 @@ image_handler_load (int idx)
file_formats [idx].save = save_sym; file_formats [idx].save = save_sym;
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_load_image (const char *file) gdk_pixbuf_load_image (const char *file)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
gint n, i; gint n, i;
FILE *f; FILE *f;
char buffer [128]; char buffer [128];
...@@ -176,17 +176,17 @@ gdk_pixbuf_load_image (const char *file) ...@@ -176,17 +176,17 @@ gdk_pixbuf_load_image (const char *file)
return NULL; return NULL;
n = fread (&buffer, 1, sizeof (buffer), f); n = fread (&buffer, 1, sizeof (buffer), f);
if (n == 0){ if (n == 0) {
fclose (f); fclose (f);
return NULL; return NULL;
} }
for (i = 0; file_formats [i].module_name; i++){ for (i = 0; file_formats [i].module_name; i++) {
if ((*file_formats [i].format_check)(buffer, n)){ if ((*file_formats [i].format_check)(buffer, n)) {
if (!file_formats [i].load) if (!file_formats [i].load)
image_handler_load (i); image_handler_load (i);
if (!file_formats [i].load){ if (!file_formats [i].load) {
fclose (f); fclose (f);
return NULL; return NULL;
} }
......
/* /* GdkPixbuf library
* gdk-pixbuf.c: Resource management.
* *
* Authors: * Copyright (C) 1999 The Free Software Foundation
* Miguel de Icaza (miguel@gnu.org) *
* Mark Crichton (crichton@gimp.org) * Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Carsten Haitzler <raster@rasterman.com>
*
* 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.
*/ */
#include <config.h> #include <config.h>
#include <glib.h>
#include <math.h> #include <math.h>
#include <glib.h>
#include <libart_lgpl/art_misc.h> #include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_affine.h> #include <libart_lgpl/art_affine.h>
#include <libart_lgpl/art_pixbuf.h> #include <libart_lgpl/art_pixbuf.h>
...@@ -16,96 +33,96 @@ ...@@ -16,96 +33,96 @@
#include <libart_lgpl/art_alphagamma.h> #include <libart_lgpl/art_alphagamma.h>
#include "gdk-pixbuf.h" #include "gdk-pixbuf.h"
void void
gdk_pixbuf_destroy (GdkPixBuf *pixbuf) gdk_pixbuf_destroy (GdkPixbuf *pixbuf)
{ {
art_pixbuf_free (pixbuf->art_pixbuf); art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = NULL; pixbuf->art_pixbuf = NULL;
g_free (pixbuf); g_free (pixbuf);
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_new (ArtPixBuf *art_pixbuf, gdk_pixbuf_new (ArtPixBuf *art_pixbuf, GdkPixbufUnrefFunc *unref_fn)
GdkPixBufUnrefFunc *unref_fn)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
if (!art_pixbuf) if (!art_pixbuf)
return NULL; return NULL;
pixbuf = g_new (GdkPixBuf, 1); pixbuf = g_new (GdkPixbuf, 1);
pixbuf->ref_count = 1; pixbuf->ref_count = 1;
pixbuf->unref_fn = unref_fn; pixbuf->unref_fn = unref_fn;
pixbuf->art_pixbuf = art_pixbuf; pixbuf->art_pixbuf = art_pixbuf;
return pixbuf; return pixbuf;
} }
void void
gdk_pixbuf_ref (GdkPixBuf *pixbuf) gdk_pixbuf_ref (GdkPixbuf *pixbuf)
{ {
g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->ref_count > 0); g_return_if_fail (pixbuf->ref_count > 0);
pixbuf->ref_count++; pixbuf->ref_count++;
} }
void void
gdk_pixbuf_unref (GdkPixBuf *pixbuf) gdk_pixbuf_unref (GdkPixbuf *pixbuf)
{ {
g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->ref_count > 0); g_return_if_fail (pixbuf->ref_count > 0);
pixbuf->ref_count--; pixbuf->ref_count--;
if (pixbuf->ref_count == 0) if (pixbuf->ref_count == 0)
gdk_pixbuf_destroy (pixbuf); gdk_pixbuf_destroy (pixbuf);
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_scale (const GdkPixBuf *pixbuf, gint w, gint h) gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
{ {
art_u8 *pixels; art_u8 *pixels;
gint rowstride; gint rowstride;
double affine[6]; double affine[6];
ArtAlphaGamma *alphagamma; ArtAlphaGamma *alphagamma;
ArtPixBuf *art_pixbuf = NULL; ArtPixBuf *art_pixbuf = NULL;
GdkPixBuf *copy = NULL; GdkPixbuf *copy = NULL;
alphagamma = NULL; alphagamma = NULL;
affine[1] = affine[2] = affine[4] = affine[5] = 0; affine[1] = affine[2] = affine[4] = affine[5] = 0;
affine[0] = w / (double)(pixbuf->art_pixbuf->width); affine[0] = w / (double)(pixbuf->art_pixbuf->width);
affine[3] = h / (double)(pixbuf->art_pixbuf->height); affine[3] = h / (double)(pixbuf->art_pixbuf->height);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */ /* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3; rowstride = w * 3;
pixels = art_alloc (h * rowstride); pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride, art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf, pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma); affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha) if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */ /* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
copy = gdk_pixbuf_new (art_pixbuf, NULL); copy = gdk_pixbuf_new (art_pixbuf, NULL);
if (!copy) if (!copy)
art_free (pixels); art_free (pixels);
return copy; return copy;
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_duplicate (const GdkPixBuf *pixbuf) gdk_pixbuf_duplicate (const GdkPixbuf *pixbuf)
{ {
GdkPixBuf *copy = g_new (GdkPixBuf, 1); GdkPixbuf *copy = g_new (GdkPixbuf, 1);
copy->ref_count = 1; copy->ref_count = 1;
copy->unref_fn = pixbuf->unref_fn; copy->unref_fn = pixbuf->unref_fn;
...@@ -114,59 +131,59 @@ gdk_pixbuf_duplicate (const GdkPixBuf *pixbuf) ...@@ -114,59 +131,59 @@ gdk_pixbuf_duplicate (const GdkPixBuf *pixbuf)
return copy; return copy;
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle) gdk_pixbuf_rotate (GdkPixbuf *pixbuf, gdouble angle)
{ {
art_u8 *pixels; art_u8 *pixels;
gint rowstride, w, h; gint rowstride, w, h;
gdouble rad; gdouble rad;
double rot[6], trans[6], affine[6]; double rot[6], trans[6], affine[6];
ArtAlphaGamma *alphagamma = NULL; ArtAlphaGamma *alphagamma = NULL;
ArtPixBuf *art_pixbuf = NULL; ArtPixBuf *art_pixbuf = NULL;
w = pixbuf->art_pixbuf->width; w = pixbuf->art_pixbuf->width;
h = pixbuf->art_pixbuf->height; h = pixbuf->art_pixbuf->height;
rad = (M_PI * angle / 180.0); rad = (M_PI * angle / 180.0);
rot[0] = cos(rad); rot[0] = cos(rad);
rot[1] = sin(rad); rot[1] = sin(rad);
rot[2] = -sin(rad); rot[2] = -sin(rad);
rot[3] = cos(rad); rot[3] = cos(rad);
rot[4] = rot[5] = 0; rot[4] = rot[5] = 0;
trans[0] = trans[3] = 1; trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0; trans[1] = trans[2] = 0;
trans[4] = -(double)w / 2.0; trans[4] = -(double)w / 2.0;
trans[5] = -(double)h / 2.0; trans[5] = -(double)h / 2.0;
art_affine_multiply(rot, trans, rot); art_affine_multiply(rot, trans, rot);
trans[0] = trans[3] = 1; trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0; trans[1] = trans[2] = 0;
trans[4] = (double)w / 2.0; trans[4] = (double)w / 2.0;
trans[5] = (double)h / 2.0; trans[5] = (double)h / 2.0;
art_affine_multiply(affine, rot, trans); art_affine_multiply(affine, rot, trans);
g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2], g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2],
affine[3], affine[4], affine[5]); affine[3], affine[4], affine[5]);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */ /* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3; rowstride = w * 3;
pixels = art_alloc (h * rowstride); pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride, art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf, pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma); affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha) if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */ /* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
art_pixbuf_free (pixbuf->art_pixbuf); art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = art_pixbuf; pixbuf->art_pixbuf = art_pixbuf;
return pixbuf; return pixbuf;
} }
#ifndef _GDK_PIXBUF_H_ /* GdkPixbuf library
#define _GDK_PIXBUF_H_ *
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Carsten Haitzler <raster@rasterman.com>
*
* 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.
*/
#ifndef GDK_PIXBUF_H
#define GDK_PIXBUF_H
#include <libart_lgpl/art_misc.h> #include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_pixbuf.h> #include <libart_lgpl/art_pixbuf.h>
#include <glib.h> #include <glib.h>
typedef struct _GdkPixBuf GdkPixBuf; #ifdef __cplusplus
typedef void (*GdkPixBufUnrefFunc) (GdkPixBuf *pixbuf); extern "C" {
#endif
struct _GdkPixBuf typedef struct _GdkPixbuf GdkPixbuf;
{ typedef void (* GdkPixbufUnrefFunc) (GdkPixbuf *pixbuf);
int ref_count;
ArtPixBuf *art_pixbuf; struct _GdkPixbuf {
GdkPixBufUnrefFunc *unref_fn; int ref_count;
ArtPixBuf *art_pixbuf;
GdkPixbufUnrefFunc *unref_fn;
}; };
GdkPixBuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
GdkPixBuf *gdk_pixbuf_new (ArtPixBuf *art_pixbuf, GdkPixbuf *gdk_pixbuf_load_image (const char *file);
GdkPixBufUnrefFunc *unref_fn); 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_new (ArtPixBuf *art_pixbuf, GdkPixbufUnrefFunc *unref_fn);
GdkPixBuf *gdk_pixbuf_duplicate (const GdkPixBuf *pixbuf);
GdkPixBuf *gdk_pixbuf_scale (const GdkPixBuf *pixbuf, gint w, gint h); void gdk_pixbuf_ref (GdkPixbuf *pixbuf);
GdkPixBuf *gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle); void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
GdkPixbuf *gdk_pixbuf_duplicate (const GdkPixbuf *pixbuf);
GdkPixbuf *gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h);
GdkPixbuf *gdk_pixbuf_rotate (GdkPixbuf *pixbuf, gdouble angle);
void gdk_pixbuf_destroy (GdkPixbuf *pixbuf);
void gdk_pixbuf_destroy (GdkPixBuf *pixbuf); GdkPixbuf *gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, int rgb_width, int rgb_height);
GdkPixBuf *gdk_pixbuf_load_image_from_rgb_d (unsigned char *data,
int rgb_width, int rgb_height);
#ifdef __cplusplus
}