Code

remove many unnecessary to_2geom and from_2geom calls
[inkscape.git] / src / helper / png-write.cpp
index 6feefec7d69c722de91a6855de8d660a4c8a1ea7..84816ad9c7b52454a8176bb37d675e286026b72b 100644 (file)
@@ -216,8 +216,8 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data)
         if (!ebp->status((float) row / ebp->height, ebp->data)) return 0;
     }
 
-    num_rows = MIN(num_rows, ebp->sheight);
-    num_rows = MIN(num_rows, ebp->height - row);
+    num_rows = MIN(num_rows, static_cast<int>(ebp->sheight));
+    num_rows = MIN(num_rows, static_cast<int>(ebp->height - row));
 
     /* Set area of interest */
     // bbox is now set to the entire image to prevent discontinuities
@@ -230,7 +230,7 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data)
     bbox.y1 = row + num_rows;
     /* Update to renderable state */
     NRGC gc(NULL);
-    nr_matrix_set_identity(&gc.transform);
+    gc.transform.set_identity();
 
     nr_arena_item_invoke_update(ebp->root, &bbox, &gc,
            NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE);
@@ -242,7 +242,7 @@ sp_export_get_rows(guchar const **rows, int row, int num_rows, void *data)
 
     for (int r = 0; r < num_rows; r++) {
         guchar *p = NR_PIXBLOCK_PX(&pb) + r * pb.rs;
-        for (int c = 0; c < ebp->width; c++) {
+        for (int c = 0; c < static_cast<int>(ebp->width); c++) {
             *p++ = ebp->r;
             *p++ = ebp->g;
             *p++ = ebp->b;
@@ -289,7 +289,7 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey)
 /**
  * Export the given document as a Portable Network Graphics (PNG) file.
  *
- * \return true if succeeded, false if an error occurred.
+ * \return true if succeeded (or if no action was taken), false if an error occurred.
  */
 bool
 sp_export_png_file(SPDocument *doc, gchar const *filename,
@@ -306,7 +306,11 @@ sp_export_png_file(SPDocument *doc, gchar const *filename,
     g_return_val_if_fail(height >= 1, false);
 
     if (!force_overwrite && !sp_ui_overwrite_file(filename)) {
-        return false;
+        /* Remark: We return true so as not to invoke an error dialog in case export is cancelled
+           by the user; currently this is safe because the callers only act when false is returned.
+           If this changes in the future we need better distinction of return types (e.g., use int)
+        */
+        return true;
     }
 
     // export with maximum blur rendering quality
@@ -338,8 +342,8 @@ sp_export_png_file(SPDocument *doc, gchar const *filename,
      * (2) a[5] = -a[3] * y1
      */
 
-    NR::Matrix const affine(NR::translate(-x0, -y0)
-                            * NR::scale(width / (x1 - x0),
+    Geom::Matrix const affine(Geom::Translate(-x0, -y0)
+                            * Geom::Scale(width / (x1 - x0),
                                         height / (y1 - y0)));
 
     //SP_PRINT_MATRIX("SVG2PNG", &affine);