From 1a02c2b616bd167a58870ad9ed33af5e042c9daf Mon Sep 17 00:00:00 2001 From: rwst Date: Thu, 22 Jun 2006 14:26:10 +0000 Subject: [PATCH] apply patch 1498946 by zbsz (fixes #1492545 "PNG resolution value export") --- src/dialogs/export.cpp | 2 +- src/file.cpp | 6 +++--- src/file.h | 2 +- src/helper/png-write.cpp | 7 ++++--- src/helper/png-write.h | 4 ++-- src/main.cpp | 2 +- src/selection-chemistry.cpp | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 3b1943c4f..a141053dc 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1070,7 +1070,7 @@ sp_export_export_clicked (GtkButton *button, GtkObject *base) /* 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 de9b615aa..5c236da82 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1091,7 +1091,7 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) 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, @@ -1168,12 +1168,12 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, 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 f18f757f6..be4927395 100644 --- a/src/file.h +++ b/src/file.h @@ -129,7 +129,7 @@ void sp_file_export_dialog (void *widget); */ 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); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 21eca1efa..c90121860 100644 --- 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) { @@ -151,6 +151,7 @@ sp_png_write_rgba_striped (const gchar *filename, int width, int height, /* 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 2d2c16544..f8011f53e 100644 --- a/src/helper/png-write.h +++ b/src/helper/png-write.h @@ -14,9 +14,9 @@ #include -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 3c3655175..aa97f3aec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -955,7 +955,7 @@ sp_do_export_png(SPDocument *doc) 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); } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 1225a66f3..352a0b6ad 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2332,7 +2332,7 @@ sp_selection_create_bitmap_copy () // 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,*/ -- 2.30.2