Fixed compiler warnings. Fixed write to unallocated memory (row_ptr), and

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.
This commit is contained in:
Federico Mena Quintero 1999-08-09 06:09:24 +00:00 committed by Arturo Espinosa
parent ecef1e1f2f
commit 49ca2615f8
7 changed files with 63 additions and 54 deletions

View File

@ -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:

View File

@ -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"
@ -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)
{

View File

@ -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"
@ -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];
@ -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;

View File

@ -181,5 +181,3 @@ GdkPixBuf *image_load(FILE * f)
}
image_save() {}

View File

@ -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." */

View File

@ -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;
}