summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7eb8664)
raw | patch | inline | side by side (parent: 7eb8664)
author | rwst <rwst@users.sourceforge.net> | |
Thu, 22 Jun 2006 14:26:10 +0000 (14:26 +0000) | ||
committer | rwst <rwst@users.sourceforge.net> | |
Thu, 22 Jun 2006 14:26:10 +0000 (14:26 +0000) |
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index 3b1943c4ff23234f0a02c42227a1b667f57e8f11..a141053dcb4e0ec5979e9fd0478d8d929e7490f8 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
/* Do export */
if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), filename,
- x0, y0, x1, y1, width, height,
+ x0, y0, x1, y1, width, height, xdpi, ydpi,
nv->pagecolor,
sp_export_progress_callback, base)) {
gchar * error;
diff --git a/src/file.cpp b/src/file.cpp
index de9b615aad4ada7996f8344316f5b2910b367c74..5c236da82aade712cd236b5dc18831455a495f65 100644 (file)
--- a/src/file.cpp
+++ b/src/file.cpp
int
sp_export_png_file(SPDocument *doc, gchar const *filename,
double x0, double y0, double x1, double y1,
- unsigned width, unsigned height,
+ unsigned width, unsigned height, double xdpi, double ydpi,
unsigned long bgcolor,
unsigned (*status)(float, void *),
void *data, bool force_overwrite,
if ((width < 256) || ((width * height) < 32768)) {
ebp.px = nr_pixelstore_64K_new(FALSE, 0);
ebp.sheight = 65536 / (4 * width);
- write_status = sp_png_write_rgba_striped(filename, width, height, sp_export_get_rows, &ebp);
+ write_status = sp_png_write_rgba_striped(filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp);
nr_pixelstore_64K_free(ebp.px);
} else {
ebp.px = g_new(guchar, 4 * 64 * width);
ebp.sheight = 64;
- write_status = sp_png_write_rgba_striped(filename, width, height, sp_export_get_rows, &ebp);
+ write_status = sp_png_write_rgba_striped(filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp);
g_free(ebp.px);
}
diff --git a/src/file.h b/src/file.h
index f18f757f667df942f89682e82ce67847894d1d83..be492739533d6916154b58b1abef6bbcef7e7a91 100644 (file)
--- a/src/file.h
+++ b/src/file.h
*/
int sp_export_png_file (SPDocument *doc, const gchar *filename,
double x0, double y0, double x1, double y1,
- unsigned int width, unsigned int height,
+ unsigned int width, unsigned int height, double xdpi, double ydpi,
unsigned long bgcolor,
unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL);
index 21eca1efa808c8dfe3017f3667136ba8e435fcca..c90121860e973bb6fac8c06abf3d714bae149ace 100644 (file)
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
@@ -53,18 +53,18 @@ sp_png_get_block_stripe (const guchar **rows, int row, int num_rows, void *data)
}
int
-sp_png_write_rgba (const gchar *filename, const guchar *px, int width, int height, int rowstride)
+sp_png_write_rgba (const gchar *filename, const guchar *px, int width, int height, double xdpi, double ydpi, int rowstride)
{
SPPNGBD bd;
bd.px = px;
bd.rowstride = rowstride;
- return sp_png_write_rgba_striped (filename, width, height, sp_png_get_block_stripe, &bd);
+ return sp_png_write_rgba_striped (filename, width, height, xdpi, ydpi, sp_png_get_block_stripe, &bd);
}
int
-sp_png_write_rgba_striped (const gchar *filename, int width, int height,
+sp_png_write_rgba_striped (const gchar *filename, int width, int height, double xdpi, double ydpi,
int (* get_rows) (const guchar **rows, int row, int num_rows, void *data),
void *data)
{
/* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */
/* note that if sRGB is present the cHRM chunk must be ignored
* on read and must be written in accordance with the sRGB profile */
+ png_set_pHYs(png_ptr, info_ptr, unsigned(xdpi / 0.0254 + 0.5), unsigned(ydpi / 0.0254 + 0.5), PNG_RESOLUTION_METER);
/* Write the file header information. REQUIRED */
png_write_info(png_ptr, info_ptr);
diff --git a/src/helper/png-write.h b/src/helper/png-write.h
index 2d2c165444a9cd6afe364f0dd6d197f0d7c13990..f8011f53e3a7e4bda25bdb4969eb726df4cc6f09 100644 (file)
--- a/src/helper/png-write.h
+++ b/src/helper/png-write.h
#include <glib/gtypes.h>
-int sp_png_write_rgba(gchar const *filename, guchar const *px, int width, int height, int rowstride);
+int sp_png_write_rgba(gchar const *filename, guchar const *px, int width, int height, double xdpi, double ydpi, int rowstride);
-int sp_png_write_rgba_striped(gchar const *filename, int width, int height,
+int sp_png_write_rgba_striped(gchar const *filename, int width, int height, double xdpi, double ydpi,
int (* get_rows) (guchar const **rows, int row, int num_rows, void *data),
void *data);
diff --git a/src/main.cpp b/src/main.cpp
index 3c3655175b4290be8ddb1e95eee552925d0b6b9f..aa97f3aecec9361bf308f67ee72f3cc5c3837d31 100644 (file)
--- a/src/main.cpp
+++ b/src/main.cpp
g_print("Bitmap saved as: %s\n", filename);
if ((width >= 1) && (height >= 1) && (width < 65536) && (height < 65536)) {
- sp_export_png_file(doc, filename, area.x0, area.y0, area.x1, area.y1, width, height, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
+ sp_export_png_file(doc, filename, area.x0, area.y0, area.x1, area.y1, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
} else {
g_warning("Calculated bitmap dimensions %d %d are out of range (1 - 65535). Nothing exported.", width, height);
}
index 1225a66f369dcbef3c0d23e87a79407ff4e2bcfd..352a0b6ad5943353c39b350242585079c10193e1 100644 (file)
// Do the export
sp_export_png_file(document, filepath,
bbox.x0, bbox.y0, bbox.x1, bbox.y1,
- width, height,
+ width, height, res, res,
(guint32) 0xffffff00,
NULL, NULL,
true, /*bool force_overwrite,*/