stream = jas_stream_memopen (NULL, -1);
if (!stream) {
- g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, _("Couldn't allocate memory for stream"));
+ g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Couldn't allocate memory for stream"));
return NULL;
}
raw_image = jas_image_decode (context->stream, -1, 0);
if (!raw_image) {
- g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, _("Couldn't decode image"));
+ g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Couldn't decode image"));
return FALSE;
}
if (width == 0 || height == 0) {
jas_image_destroy(raw_image);
- g_set_error (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
- _("Transformed JPEG2000 has zero width or height"));
+ g_set_error_literal (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Transformed JPEG2000 has zero width or height"));
return FALSE;
}
}
if ((num_components != 3 && num_components != 4 && num_components != 1) ||
(colourspace_family != JAS_CLRSPC_FAM_RGB && colourspace_family != JAS_CLRSPC_FAM_GRAY)) {
jas_image_destroy (raw_image);
- g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_UNKNOWN_TYPE, _("Image type currently not supported"));
+ g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
+ _("Image type currently not supported"));
return FALSE;
}
profile = jas_cmprof_createfromclrspc (JAS_CLRSPC_SRGB);
if (!profile) {
jas_image_destroy (raw_image);
- g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, _("Couldn't allocate memory for color profile"));
+ g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Couldn't allocate memory for color profile"));
return FALSE;
}
image = jas_image_chclrspc (raw_image, profile, JAS_CMXFORM_INTENT_PER);
if (!image) {
jas_image_destroy (raw_image);
- g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, _("Couldn't allocate memory for color profile"));
+ g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Couldn't allocate memory for color profile"));
return FALSE;
}
} else {
if (!context->pixbuf) {
int bits_per_sample;
- guchar *data;
/* Unfortunately, gdk-pixbuf doesn't support 16 bpp images
* bits_per_sample = jas_image_cmptprec (image, 0);
*/
bits_per_sample = 8;
- data = g_try_malloc0 (context->width * context->height * bits_per_sample / 8);
- if (data == NULL) {
- g_set_error (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
- _("Insufficient memory to open JPEG 2000 file"));
- return FALSE;
- }
context->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
FALSE, bits_per_sample,
context->width, context->height);
+ if (context->pixbuf == NULL) {
+ g_set_error_literal (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Insufficient memory to open JPEG 2000 file"));
+ return FALSE;
+ }
if (context->prepared_func)
context->prepared_func (context->pixbuf, NULL, context->user_data);
}
struct jasper_context *context = (struct jasper_context *) data;
if (jas_stream_write (context->stream, buf, size) < 0) {
- g_set_error (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, _("Couldn't allocate memory to buffer image data"));
+ g_set_error_literal (error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+ _("Couldn't allocate memory to buffer image data"));
return FALSE;
}