summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdk-pixbuf/ChangeLog11
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.c45
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c29
-rw-r--r--gdk-pixbuf/io-gif.c2
-rw-r--r--gdk-pixbuf/io-jpeg.c4
-rw-r--r--gdk-pixbuf/io-png.c24
-rw-r--r--gdk-pixbuf/io-xpm.c2
7 files changed, 63 insertions, 54 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index 34dbf9835..90125f1a9 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,14 @@
+1999-08-09 Federico Mena Quintero <federico@nuclecu.unam.mx>
+
+ * src/io-png.c (image_save): Fixed compiler warnings. Fixed write
+ to unallocated memory (row_ptr), and fixed its type as well. Take
+ into account the ArtPixbuf's rowstride when assigning the row
+ pointers.
+
+ * src/gdk-pixbuf.c: Fixup includes.
+
+ * src/gdk-pixbuf-io.c: Likewise.
+
Sat Jul 31 19:19:47 CEST 1999
* src/gdk-pixbuf-io.c:
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 7a06da6a3..7b644000e 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -4,8 +4,10 @@
* Author:
* Miguel de Icaza (miguel@gnu.org)
*/
+
#include <config.h>
#include <stdio.h>
+#include <string.h>
#include <glib.h>
#include <gmodule.h>
#include "gdk-pixbuf.h"
@@ -37,7 +39,7 @@ pixbuf_check_jpeg (unsigned char *buffer, int size)
if (buffer [0] != 0xff || buffer [1] != 0xd8)
return FALSE;
-
+
return TRUE;
}
@@ -47,18 +49,18 @@ pixbuf_check_tiff (unsigned char *buffer, int size)
if (size < 10)
return FALSE;
- if (buffer [0] == 'M' &&
- buffer [1] == 'M' &&
- buffer [2] == 0 &&
+ 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 &&
+ if (buffer [0] == 'I' &&
+ buffer [1] == 'I' &&
+ buffer [2] == 0x2a &&
buffer [3] == 0)
return TRUE;
-
+
return FALSE;
}
@@ -67,10 +69,10 @@ pixbuf_check_gif (unsigned char *buffer, int size)
{
if (size < 20)
return FALSE;
-
+
if (strncmp (buffer, "GIF8", 4) == 0)
return TRUE;
-
+
return FALSE;
}
@@ -79,10 +81,10 @@ pixbuf_check_xpm (unsigned char *buffer, int size)
{
if (size < 20)
return FALSE;
-
+
if (strncmp (buffer, "/* XPM */", 9) == 0)
return TRUE;
-
+
return FALSE;
}
@@ -91,10 +93,10 @@ pixbuf_check_bmp (unsigned char *buffer, int size)
{
if (size < 20)
return FALSE;
-
+
if (buffer [0] != 'B' || buffer [1] != 'M')
return FALSE;
-
+
return TRUE;
}
@@ -133,15 +135,6 @@ static struct {
{ NULL, NULL, NULL, NULL, NULL }
};
-static int
-image_file_format (const char *file)
-{
- FILE *f = fopen (file, "r");
-
- if (!f)
- return -1;
-}
-
static void
image_handler_load (int idx)
{
@@ -149,8 +142,8 @@ image_handler_load (int idx)
char *path;
GModule *module;
void *load_sym, *save_sym;
-
- module_name = g_strconcat ("pixbuf-",
+
+ module_name = g_strconcat ("pixbuf-",
file_formats [idx].module_name, NULL);
path = g_module_build_path (PIXBUF_LIBDIR, module_name);
g_free (module_name);
@@ -184,7 +177,7 @@ gdk_pixbuf_load_image (const char *file)
n = fread (&buffer, 1, sizeof (buffer), f);
if (n == 0){
- fclose (f);
+ fclose (f);
return NULL;
}
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index c786c1ddf..82acf793a 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -5,11 +5,14 @@
* Miguel de Icaza (miguel@gnu.org)
* Mark Crichton (crichton@gimp.org)
*/
+
#include <config.h>
#include <glib.h>
#include <math.h>
#include <libart_lgpl/art_misc.h>
-#include <libart_lgpl/art_rgb_affine.h>
+#include <libart_lgpl/art_affine.h>
+#include <libart_lgpl/art_pixbuf.h>
+#include <libart_lgpl/art_rgb_pixbuf_affine.h>
#include <libart_lgpl/art_alphagamma.h>
#include "gdk-pixbuf.h"
@@ -25,7 +28,7 @@ void
gdk_pixbuf_ref (GdkPixBuf *pixbuf)
{
g_return_if_fail (pixbuf != NULL);
-
+
pixbuf->ref_count++;
}
@@ -34,7 +37,7 @@ 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);
@@ -43,7 +46,6 @@ gdk_pixbuf_unref (GdkPixBuf *pixbuf)
GdkPixBuf *
gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
{
- GdkPixBuf *spb;
art_u8 *pixels;
gint rowstride;
double affine[6];
@@ -53,8 +55,8 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
alphagamma = NULL;
affine[1] = affine[2] = affine[4] = affine[5] = 0;
-
-
+
+
affine[0] = w / (double)(pixbuf->art_pixbuf->width);
affine[3] = h / (double)(pixbuf->art_pixbuf->height);
@@ -62,15 +64,15 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
rowstride = w * 3;
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,
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
- art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
- else
- art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
+ art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
+ else
+ art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = art_pixbuf;
@@ -81,7 +83,6 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h)
GdkPixBuf *
gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle)
{
- GdkPixBuf *rotate;
art_u8 *pixels;
gint rowstride, w, h;
gdouble rad;
@@ -126,9 +127,9 @@ gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle)
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
- art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
- else
- art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
+ art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
+ else
+ art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = art_pixbuf;
diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c
index 7db7adece..926964f39 100644
--- a/gdk-pixbuf/io-gif.c
+++ b/gdk-pixbuf/io-gif.c
@@ -181,5 +181,3 @@ GdkPixBuf *image_load(FILE * f)
}
image_save() {}
-
-
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 564626242..8e2a830bd 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -42,7 +42,7 @@ g_JPEGFatalErrorHandler(j_common_ptr cinfo)
GdkPixBuf *image_load(FILE *f)
{
int w,h,i,j;
- art_u8 *pixels=NULL, *dptr, *fptr, *pptr;
+ art_u8 *pixels=NULL, *dptr;
unsigned char *lines[4], /* Used to expand rows, via rec_outbuf_height, from
the header file:
"* Usually rec_outbuf_height will be 1 or 2, at most 4." */
@@ -123,7 +123,7 @@ GdkPixBuf *image_load(FILE *f)
}
pixbuf->ref_count = 0;
pixbuf->unref_func = NULL;
-
+
return pixbuf;
}
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index 514b13c8e..9746ed21c 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -170,12 +170,12 @@ int image_save(GdkPixBuf *pixbuf, FILE *file)
png_infop info_ptr;
art_u8 *data;
gint y, h, w;
- png_bytep row_ptr;
+ png_bytepp row_ptr;
png_color_8 sig_bit;
gint type;
-
- g_return_val_if_fail(file != NULL, NULL);
- g_return_val_if_fail(pixbuf != NULL, NULL);
+
+ g_return_val_if_fail(file != NULL, FALSE);
+ g_return_val_if_fail(pixbuf != NULL, FALSE);
h = pixbuf->art_pixbuf->height;
w = pixbuf->art_pixbuf->width;
@@ -184,20 +184,20 @@ int image_save(GdkPixBuf *pixbuf, FILE *file)
NULL, NULL, NULL);
if (png_ptr == NULL) {
fclose(file);
- return NULL;
+ return FALSE;
}
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
fclose(file);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
- return NULL;
+ return FALSE;
}
if (setjmp(png_ptr->jmpbuf)) {
fclose(file);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
- return NULL;
+ return FALSE;
}
png_init_io(png_ptr, file);
@@ -218,18 +218,24 @@ int image_save(GdkPixBuf *pixbuf, FILE *file)
png_set_packing(png_ptr);
data = pixbuf->art_pixbuf->pixels;
+ row_ptr = g_new(png_byte *, h);
- for (y = 0; y < h; y++) {
+ for (y = 0; y < h; y++)
+ row_ptr[y] = data + y * pixbuf->art_pixbuf->rowstride;
+#if 0
+ {
if (pixbuf->art_pixbuf->has_alpha)
row_ptr[y] = data + (w * y * 4);
else
row_ptr[y] = data + (w * y * 3);
}
+#endif
png_write_image(png_ptr, row_ptr);
+ g_free (row_ptr);
+
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return TRUE;
}
-
diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c
index 98c7532f1..b97fca2f1 100644
--- a/gdk-pixbuf/io-xpm.c
+++ b/gdk-pixbuf/io-xpm.c
@@ -342,7 +342,7 @@ static GdkPixBuf *
color->transparent = FALSE;
color_name = xpm_extract_color(buffer);
-
+
if ((color_name == NULL) || (g_strcasecmp(color_name, "None") == 0)
|| (gdk_color_parse(color_name, &color->color) == FALSE)) {
color->transparent = TRUE;