Fixed so we do not create a separate pixel buffer when reading in image -
1999-11-08 Michael Fulbright <drmike@redhat.com> * src/io-pnm.c image_load (): Fixed so we do not create a separate pixel buffer when reading in image - we reuse the pixel data in the GdkPixbuf structure instead.
This commit is contained in:
committed by
Michael Fulbright
parent
6ef7f093d4
commit
ce83490d75
@ -1,3 +1,9 @@
|
|||||||
|
1999-11-08 Michael Fulbright <drmike@redhat.com>
|
||||||
|
|
||||||
|
* src/io-pnm.c image_load (): Fixed so we do not create a separate
|
||||||
|
pixel buffer when reading in image - we reuse the pixel data in
|
||||||
|
the GdkPixbuf structure instead.
|
||||||
|
|
||||||
1999-11-08 Michael Fulbright <drmike@redhat.com>
|
1999-11-08 Michael Fulbright <drmike@redhat.com>
|
||||||
|
|
||||||
* src/io-pnm.c pnm_read_ascii_scanline (): Added support for
|
* src/io-pnm.c pnm_read_ascii_scanline (): Added support for
|
||||||
|
|||||||
@ -612,8 +612,8 @@ image_load (FILE *f)
|
|||||||
/* ran out of data and we haven't exited main loop */
|
/* ran out of data and we haven't exited main loop */
|
||||||
/* something is wrong */
|
/* something is wrong */
|
||||||
if (inbuf->bytes_left == 0) {
|
if (inbuf->bytes_left == 0) {
|
||||||
if (context.pixels)
|
if (context.pixbuf)
|
||||||
g_free (context.pixels);
|
gdk_pixbuf_unref (context.pixbuf);
|
||||||
g_warning ("io-pnm.c: Ran out of data...\n");
|
g_warning ("io-pnm.c: Ran out of data...\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -641,8 +641,20 @@ image_load (FILE *f)
|
|||||||
|
|
||||||
context.pixels = g_malloc (context.height *
|
context.pixels = g_malloc (context.height *
|
||||||
context.width * 3);
|
context.width * 3);
|
||||||
if (!context.pixels)
|
|
||||||
return NULL;
|
context.pixbuf = gdk_pixbuf_new(ART_PIX_RGB,
|
||||||
|
/*have_alpha*/ FALSE,
|
||||||
|
8,
|
||||||
|
context.width,
|
||||||
|
context.height);
|
||||||
|
|
||||||
|
|
||||||
|
if (context.pixbuf == NULL) {
|
||||||
|
/* Failed to allocate memory */
|
||||||
|
g_error ("Couldn't allocate gdkpixbuf");
|
||||||
|
}
|
||||||
|
|
||||||
|
context.pixels = context.pixbuf->art_pixbuf->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we got here we're reading image data */
|
/* if we got here we're reading image data */
|
||||||
@ -652,8 +664,8 @@ image_load (FILE *f)
|
|||||||
if (rc == PNM_SUSPEND) {
|
if (rc == PNM_SUSPEND) {
|
||||||
break;
|
break;
|
||||||
} else if (rc == PNM_FATAL_ERR) {
|
} else if (rc == PNM_FATAL_ERR) {
|
||||||
if (context.pixels)
|
if (context.pixbuf)
|
||||||
g_free (context.pixels);
|
gdk_pixbuf_unref (context.pixbuf);
|
||||||
g_warning ("io-pnm.c: error reading rows..\n");
|
g_warning ("io-pnm.c: error reading rows..\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -717,8 +729,9 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
|
|||||||
src->skip_next = num_bytes - num_can_do;
|
src->skip_next = num_bytes - num_can_do;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* func - called when we have pixmap created (but no image data)
|
* func - called when we have pixmap created (but no image data)
|
||||||
* user_data - passed as arg 1 to func
|
* user_data - passed as arg 1 to func
|
||||||
@ -730,34 +743,18 @@ image_begin_load (ModulePreparedNotifyFunc prepared_func,
|
|||||||
ModuleUpdatedNotifyFunc updated_func,
|
ModuleUpdatedNotifyFunc updated_func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
JpegProgContext *context;
|
PnmLoaderContext *context;
|
||||||
my_source_mgr *src;
|
|
||||||
|
|
||||||
context = g_new0 (JpegProgContext, 1);
|
context = g_new0 (JpegProgContext, 1);
|
||||||
context->prepared_func = prepared_func;
|
context->prepared_func = prepared_func;
|
||||||
context->updated_func = updated_func;
|
context->updated_func = updated_func;
|
||||||
context->user_data = user_data;
|
context->user_data = user_data;
|
||||||
context->pixbuf = NULL;
|
context->pixbuf = context->pixels = NULL;
|
||||||
context->got_header = FALSE;
|
context->got_header = FALSE;
|
||||||
context->did_prescan = FALSE;
|
context->did_prescan = FALSE;
|
||||||
context->src_initialized = FALSE;
|
|
||||||
|
|
||||||
/* create libjpeg structures */
|
context->inbuf.bytes_left = 0;
|
||||||
jpeg_create_decompress (&context->cinfo);
|
context->inbuf.next_byte = NULL;
|
||||||
|
|
||||||
context->cinfo.src = (struct jpeg_source_mgr *) g_new0 (my_source_mgr, 1);
|
|
||||||
src = (my_src_ptr) context->cinfo.src;
|
|
||||||
|
|
||||||
context->cinfo.err = jpeg_std_error (&context->jerr.pub);
|
|
||||||
|
|
||||||
src = (my_src_ptr) context->cinfo.src;
|
|
||||||
src->pub.init_source = init_source;
|
|
||||||
src->pub.fill_input_buffer = fill_input_buffer;
|
|
||||||
src->pub.skip_input_data = skip_input_data;
|
|
||||||
src->pub.resync_to_restart = jpeg_resync_to_restart;
|
|
||||||
src->pub.term_source = term_source;
|
|
||||||
src->pub.bytes_in_buffer = 0;
|
|
||||||
src->pub.next_input_byte = NULL;
|
|
||||||
|
|
||||||
return (gpointer) context;
|
return (gpointer) context;
|
||||||
}
|
}
|
||||||
@ -770,22 +767,13 @@ image_begin_load (ModulePreparedNotifyFunc prepared_func,
|
|||||||
void
|
void
|
||||||
image_stop_load (gpointer data)
|
image_stop_load (gpointer data)
|
||||||
{
|
{
|
||||||
JpegProgContext *context = (JpegProgContext *) data;
|
PnmLoaderContext *context = (PnmLoaderContext *) data;
|
||||||
|
|
||||||
g_return_if_fail (context != NULL);
|
g_return_if_fail (context != NULL);
|
||||||
|
|
||||||
if (context->pixbuf)
|
if (context->pixbuf)
|
||||||
gdk_pixbuf_unref (context->pixbuf);
|
gdk_pixbuf_unref (context->pixbuf);
|
||||||
|
|
||||||
jpeg_finish_decompress(&context->cinfo);
|
|
||||||
jpeg_destroy_decompress(&context->cinfo);
|
|
||||||
|
|
||||||
if (context->cinfo.src) {
|
|
||||||
my_src_ptr src = (my_src_ptr) context->cinfo.src;
|
|
||||||
|
|
||||||
g_free (src);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (context);
|
g_free (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user