summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3bf35ec)
raw | patch | inline | side by side (parent: 3bf35ec)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 16 Nov 2007 18:43:48 +0000 (18:43 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 16 Nov 2007 18:43:48 +0000 (18:43 +0000) |
src/dialogs/export.cpp | patch | blob | history | |
src/helper/png-write.cpp | patch | blob | history | |
src/helper/png-write.h | patch | blob | history | |
src/main.cpp | patch | blob | history |
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index 1b74afb7e13b4b8be2d2bd3c7fd520b78471bf4e..d26a5cde15dbc326528db9a67424ea45c94d87d8 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
#include "io/sys.h"
#include "helper/png-write.h"
+#include <png.h>
#define SP_EXPORT_MIN_SIZE 1.0
G_CALLBACK (sp_export_area_x_value_changed),
dlg );
- sp_export_spinbutton_new ( "width", 0.0, -1000000.0, 1000000.0, 0.1, 1.0,
+ sp_export_spinbutton_new ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
us->gobj(), GTK_WIDGET(t->gobj()), 4, 0, _("Width:"), NULL, EXPORT_COORD_PRECISION, 1,
G_CALLBACK
(sp_export_area_width_value_changed),
G_CALLBACK (sp_export_area_y_value_changed),
dlg );
- sp_export_spinbutton_new ( "height", 0.0, -1000000.0, 1000000.0, 0.1, 1.0,
+ sp_export_spinbutton_new ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
us->gobj(), GTK_WIDGET(t->gobj()), 4, 1, _("Height:"), NULL, EXPORT_COORD_PRECISION, 1,
G_CALLBACK (sp_export_area_height_value_changed),
dlg );
float const y1 = sp_export_value_get_px(base, "y1");
float const xdpi = sp_export_value_get(base, "xdpi");
float const ydpi = sp_export_value_get(base, "ydpi");
- int const width = int(sp_export_value_get(base, "bmwidth") + 0.5);
- int const height = int(sp_export_value_get(base, "bmheight") + 0.5);
+ unsigned long int const width = int(sp_export_value_get(base, "bmwidth") + 0.5);
+ unsigned long int const height = int(sp_export_value_get(base, "bmheight") + 0.5);
if (filename == NULL || *filename == '\0') {
sp_ui_error_dialog(_("You have to enter a filename"));
gchar *fn = g_path_get_basename (filename_ext);
- gchar *progress_text = g_strdup_printf (_("Exporting %s (%d x %d)"), fn, width, height);
+ gchar *progress_text = g_strdup_printf (_("Exporting %s (%lu x %lu)"), fn, width, height);
g_free (fn);
GtkWidget *prog_dlg = create_progress_dialog (base, progress_text);
g_free (progress_text);
index 14c1ec32533cc1cee4da5ef6248276869c0a686d..6feefec7d69c722de91a6855de8d660a4c8a1ea7 100644 (file)
--- a/src/helper/png-write.cpp
+++ b/src/helper/png-write.cpp
static unsigned int const MAX_STRIPE_SIZE = 1024*1024;
struct SPEBP {
- int width, height, sheight;
+ unsigned long int width, height, sheight;
guchar r, g, b, a;
NRArenaItem *root; // the root arena item to show; it is assumed that all unneeded items are hidden
guchar *px;
} SPPNGBD;
static bool
-sp_png_write_rgba_striped(gchar const *filename, int width, int height, double xdpi, double ydpi,
+sp_png_write_rgba_striped(gchar const *filename, unsigned long int width, unsigned long int height, double xdpi, double ydpi,
int (* get_rows)(guchar const **rows, int row, int num_rows, void *data),
void *data)
{
bool
sp_export_png_file(SPDocument *doc, gchar const *filename,
double x0, double y0, double x1, double y1,
- unsigned width, unsigned height, double xdpi, double ydpi,
+ unsigned long width, unsigned long height, double xdpi, double ydpi,
unsigned long bgcolor,
unsigned (*status)(float, void *),
void *data, bool force_overwrite,
diff --git a/src/helper/png-write.h b/src/helper/png-write.h
index 3f1e1761f17da26dbc0b79283814c063723667cd..1217ba27694b9376526af6f2a5a462eb318fb629 100644 (file)
--- a/src/helper/png-write.h
+++ b/src/helper/png-write.h
struct SPDocument;
bool sp_export_png_file (SPDocument *doc, gchar const *filename,
- double x0, double y0, double x1, double y1,
- 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);
+ double x0, double y0, double x1, double y1,
+ unsigned long int width, unsigned long int height, double xdpi, double ydpi,
+ unsigned long bgcolor,
+ unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL);
#endif
diff --git a/src/main.cpp b/src/main.cpp
index d70a7a030c4e40154f2eba43d8ea5b66d9d762c9..99e90b7b509e4451ba52148360e8649352da2d8d 100644 (file)
--- a/src/main.cpp
+++ b/src/main.cpp
#include "main-cmdlineact.h"
+#include <png.h>
+
enum {
SP_ARG_NONE,
SP_ARG_NOGUI,
if (dpi == 0.0)
dpi = PX_PER_IN;
- gint width = 0;
- gint height = 0;
+ unsigned long int width = 0;
+ unsigned long int height = 0;
if (sp_export_width) {
- width = atoi(sp_export_width);
- if ((width < 1) || (width > 65536)) {
- g_warning("Export width %d out of range (1 - 65536). Nothing exported.", width);
+ width = strtoul(sp_export_width, NULL, 0);
+ if ((width < 1) || (width > PNG_UINT_31_MAX) || (errno == ERANGE) ) {
+ g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX);
return;
}
dpi = (gdouble) width * PX_PER_IN / (area.x1 - area.x0);
}
if (sp_export_height) {
- height = atoi(sp_export_height);
- if ((height < 1) || (height > 65536)) {
- g_warning("Export height %d out of range (1 - 65536). Nothing exported.", width);
+ height = strtoul(sp_export_height, NULL, 0);
+ if ((height < 1) || (height > PNG_UINT_31_MAX)) {
+ g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX);
return;
}
dpi = (gdouble) height * PX_PER_IN / (area.y1 - area.y0);
}
if (!sp_export_width) {
- width = (gint) ((area.x1 - area.x0) * dpi / PX_PER_IN + 0.5);
+ width = (unsigned long int) ((area.x1 - area.x0) * dpi / PX_PER_IN + 0.5);
}
if (!sp_export_height) {
- height = (gint) ((area.y1 - area.y0) * dpi / PX_PER_IN + 0.5);
+ height = (unsigned long int) ((area.y1 - area.y0) * dpi / PX_PER_IN + 0.5);
}
guint32 bgcolor = 0x00000000;
g_print("Background RRGGBBAA: %08x\n", bgcolor);
- g_print("Area %g:%g:%g:%g exported to %d x %d pixels (%g dpi)\n", area.x0, area.y0, area.x1, area.y1, width, height, dpi);
+ g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area.x0, area.y0, area.x1, area.y1, width, height, dpi);
g_print("Bitmap saved as: %s\n", filename);
- if ((width >= 1) && (height >= 1) && (width < 65536) && (height < 65536)) {
+ if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {
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);
+ g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX);
}
g_slist_free (items);