summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac6ced4)
raw | patch | inline | side by side (parent: ac6ced4)
author | theAdib <theAdib@users.sourceforge.net> | |
Mon, 11 May 2009 22:08:17 +0000 (22:08 +0000) | ||
committer | theAdib <theAdib@users.sourceforge.net> | |
Mon, 11 May 2009 22:08:17 +0000 (22:08 +0000) |
src/display/nr-filter-image.cpp | patch | blob | history | |
src/helper/pixbuf-ops.cpp | patch | blob | history | |
src/helper/png-write.cpp | patch | blob | history |
index 1cfe97125d1d27bdfa03e9c9896abab83522a286..b50a66086e87fac3ae1ad17aec336a3404cbc159 100644 (file)
has_alpha = true;
if (image_pixbuf) g_free(image_pixbuf);
- image_pixbuf = g_new(unsigned char, 4 * width * height);
- memset(image_pixbuf, 0x00, 4 * width * height);
-
- NRGC gc(NULL);
- /* Update to renderable state */
- double sf = 1.0;
- Geom::Matrix t(Geom::Scale(sf, sf));
- nr_arena_item_set_transform(ai, &t);
- gc.transform.setIdentity();
- nr_arena_item_invoke_update( ai, NULL, &gc,
- NR_ARENA_ITEM_STATE_ALL,
- NR_ARENA_ITEM_STATE_NONE );
- nr_pixblock_setup_extern(pb, NR_PIXBLOCK_MODE_R8G8B8A8N,
- (int)rect.x0, (int)rect.y0, (int)rect.x1, (int)rect.y1,
- image_pixbuf, 4 * width, FALSE, FALSE );
-
- nr_arena_item_invoke_render(NULL, ai, &rect, pb, NR_ARENA_ITEM_RENDER_NO_CACHE);
-
+ image_pixbuf = g_try_new(unsigned char, 4L * width * height);
+ if(image_pixbuf != NULL)
+ {
+ memset(image_pixbuf, 0x00, 4 * width * height);
+
+ NRGC gc(NULL);
+ /* Update to renderable state */
+ double sf = 1.0;
+ Geom::Matrix t(Geom::Scale(sf, sf));
+ nr_arena_item_set_transform(ai, &t);
+ gc.transform.setIdentity();
+ nr_arena_item_invoke_update( ai, NULL, &gc,
+ NR_ARENA_ITEM_STATE_ALL,
+ NR_ARENA_ITEM_STATE_NONE );
+ nr_pixblock_setup_extern(pb, NR_PIXBLOCK_MODE_R8G8B8A8N,
+ (int)rect.x0, (int)rect.y0, (int)rect.x1, (int)rect.y1,
+ image_pixbuf, 4 * width, FALSE, FALSE );
+
+ nr_arena_item_invoke_render(NULL, ai, &rect, pb, NR_ARENA_ITEM_RENDER_NO_CACHE);
+ }
+ else
+ {
+ g_warning("FilterImage::render: not enough memory to create pixel buffer. Need %ld.", 4L * width * height);
+ }
nr_arena_item_unref(ai);
nr_object_unref((NRObject *) arena);
}
index 49a8cc28c63b7e5f320f63d56a55f7ef72e83430..c7984137ae1f503306eb0ea2a08b81ae37f4246b 100644 (file)
{
+ GdkPixbuf* pixbuf = NULL;
/* Create new arena for offscreen rendering*/
NRArena *arena = NRArena::create();
nr_arena_set_renderoffscreen(arena);
nr_arena_item_invoke_update(root, &final_bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE);
- guchar *px = g_new(guchar, 4 * width * height);
+ guchar *px = g_try_new(guchar, 4L * width * height);
- NRPixBlock B;
- nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N,
- final_bbox.x0, final_bbox.y0, final_bbox.x1, final_bbox.y1,
- px, 4 * width, FALSE, FALSE );
-
- unsigned char dtc[4];
- dtc[0] = NR_RGBA32_R(bgcolor);
- dtc[1] = NR_RGBA32_G(bgcolor);
- dtc[2] = NR_RGBA32_B(bgcolor);
- dtc[3] = NR_RGBA32_A(bgcolor);
+ if(px != NULL)
+ {
- for (unsigned int fy = 0; fy < height; fy++) {
- guchar *p = NR_PIXBLOCK_PX(&B) + fy * B.rs;
- for (unsigned int fx = 0; fx < width; fx++) {
- for (int i = 0; i < 4; i++) {
- *p++ = dtc[i];
+ NRPixBlock B;
+ g_warning("sp_generate_internal_bitmap: nr_pixblock_setup_extern.");
+ nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N,
+ final_bbox.x0, final_bbox.y0, final_bbox.x1, final_bbox.y1,
+ px, 4 * width, FALSE, FALSE );
+
+ unsigned char dtc[4];
+ dtc[0] = NR_RGBA32_R(bgcolor);
+ dtc[1] = NR_RGBA32_G(bgcolor);
+ dtc[2] = NR_RGBA32_B(bgcolor);
+ dtc[3] = NR_RGBA32_A(bgcolor);
+
+ for (unsigned int fy = 0; fy < height; fy++) {
+ guchar *p = NR_PIXBLOCK_PX(&B) + fy * B.rs;
+ for (unsigned int fx = 0; fx < width; fx++) {
+ for (int i = 0; i < 4; i++) {
+ *p++ = dtc[i];
+ }
}
}
- }
-
- nr_arena_item_invoke_render(NULL, root, &final_bbox, &B, NR_ARENA_ITEM_RENDER_NO_CACHE );
+
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB,
- TRUE,
- 8, width, height, width * 4,
- (GdkPixbufDestroyNotify)g_free,
- NULL);
+ nr_arena_item_invoke_render(NULL, root, &final_bbox, &B, NR_ARENA_ITEM_RENDER_NO_CACHE );
+ pixbuf = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB,
+ TRUE,
+ 8, width, height, width * 4,
+ (GdkPixbufDestroyNotify)g_free,
+ NULL);
+ }
+ else
+ {
+ g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %ld.", 4L * width * height);
+ }
sp_item_invoke_hide (SP_ITEM(sp_document_root(doc)), dkey);
nr_object_unref((NRObject *) arena);
index 0e056e98149d7202d476136da11b67727bfc804d..3ac9006800b30f978e6906d999bce4878f26cbca 100644 (file)
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
png_uint_32 r;
g_return_val_if_fail(filename != NULL, false);
+ g_return_val_if_fail(data != NULL, false);
/* open the file */
nr_pixelstore_64K_free(ebp.px);
} else {
ebp.sheight = 64;
- ebp.px = g_new(guchar, 4 * ebp.sheight * width);
+ ebp.px = g_try_new(guchar, 4 * ebp.sheight * width);
write_status = sp_png_write_rgba_striped(doc, path, width, height, xdpi, ydpi, sp_export_get_rows, &ebp);
g_free(ebp.px);
}