summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5571c88)
raw | patch | inline | side by side (parent: 5571c88)
author | theadib <theadib@users.sourceforge.net> | |
Wed, 16 Jan 2008 23:31:51 +0000 (23:31 +0000) | ||
committer | theadib <theadib@users.sourceforge.net> | |
Wed, 16 Jan 2008 23:31:51 +0000 (23:31 +0000) |
index b3cf1fa26e0b9d8db4f5617b775e1cebdb833754..b163f2aff4ff29093e3f79b73c764d27825b167d 100644 (file)
return TRUE;}
static bool
-ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap)
+ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool filtertobitmap, int resolution)
{
CairoRenderer *renderer;
CairoRenderContext *ctx;
ctx->setPSLevel(level);
ctx->setTextToPath(texttopath);
ctx->setFilterToBitmap(filtertobitmap);
+ ctx->setBitmapResolution(resolution);
bool ret = ctx->setPsTarget(filename);
if(ret) {
@@ -149,11 +150,28 @@ CairoPsOutput::save (Inkscape::Extension::Output *mod, SPDocument *doc, const gc
g_warning("Parameter <blurToBitmap> might not exists");
}
+ int old_bitmapResolution = 72;
+ int new_bitmapResolution = 72;
+ try {
+ old_bitmapResolution = ext->get_param_int("resolution");
+ new_bitmapResolution = mod->get_param_int("resolution");
+ ext->set_param_int("resolution", new_bitmapResolution);
+ }
+ catch(...) {
+ g_warning("Parameter <resolution> might not exists");
+ }
+
gchar * final_name;
final_name = g_strdup_printf("> %s", uri);
- ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap);
+ ret = ps_print_document_to_file(doc, final_name, level, new_textToPath, new_blurToBitmap, new_bitmapResolution);
g_free(final_name);
+ try {
+ ext->set_param_int("resolution", old_bitmapResolution);
+ }
+ catch(...) {
+ g_warning("Parameter <resolution> might not exists");
+ }
try {
ext->set_param_bool("blurToBitmap", old_blurToBitmap);
}
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 4c4fd58b24b7b2628cb82fec45d27d07d384fbd5..d7fbbc1aa90aac4939567c01612c4ace0a13290b 100644 (file)
_ps_level(1),
_is_texttopath(FALSE),
_is_filtertobitmap(FALSE),
+ _bitmapresolution(72),
_stream(NULL),
_is_valid(FALSE),
_vector_based_target(FALSE),
_ps_level = level;
}
+unsigned int CairoRenderContext::getPSLevel(void)
+{
+ return _ps_level;
+}
+
void CairoRenderContext::setPDFLevel(unsigned int level)
{
_pdf_level = level;
_is_filtertobitmap = filtertobitmap;
}
+bool CairoRenderContext::getFilterToBitmap(void)
+{
+ return _is_filtertobitmap;
+}
+
+void CairoRenderContext::setBitmapResolution(int resolution)
+{
+ _bitmapresolution = resolution;
+}
+
+int CairoRenderContext::getBitmapResolution(void)
+{
+ return _bitmapresolution;
+}
+
cairo_surface_t*
CairoRenderContext::getSurface(void)
{
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index 58b0a10e2812b814c92ab75204f68686e1004291..5950434675903749433ec83e2b120da6e3f3c3f9 100644 (file)
bool setSurfaceTarget(cairo_surface_t *surface, bool is_vector);
void setPSLevel(unsigned int level);
+ unsigned int getPSLevel(void);
void setPDFLevel(unsigned int level);
void setTextToPath(bool texttopath);
+ bool getTextToPath(void);
void setFilterToBitmap(bool filtertobitmap);
+ bool getFilterToBitmap(void);
+ void setBitmapResolution(int resolution);
+ int getBitmapResolution(void);
/** Creates the cairo_surface_t for the context with the
given width, height and with the currently set target
unsigned int _ps_level;
bool _is_texttopath;
bool _is_filtertobitmap;
+ int _bitmapresolution;
FILE *_stream;
index 228154f049197697c377cc9f3274d389d8bb6716..22b2dd606a73db83d009d28d6628f687abdb577f 100644 (file)
NR::Matrix const i2d = sp_item_i2d_affine(item);
SPStyle* style = SP_OBJECT_STYLE (item);
- if(style->filter.set != 0) {
- sp_asbitmap_render(item, ctx);
- return;
- }
CairoRenderer *renderer = ctx->getRenderer();
NRBPath bp;
double res;
/** @TODO reimplement the resolution stuff
*/
- res = PX_PER_IN;
+ res = ctx->getBitmapResolution();
+ if(res == 0) {
+ res = PX_PER_IN;
+ }
+
// The width and height of the bitmap in pixels
unsigned width = (unsigned) floor ((bbox.x1 - bbox.x0) * res / PX_PER_IN);
static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx)
{
SPStyle* style = SP_OBJECT_STYLE (item);
- if(style->filter.set != 0) {
+ if((ctx->getFilterToBitmap() == TRUE) && (style->filter.set != 0)) {
return sp_asbitmap_render(item, ctx);
}