Code

replace text strings by ints for tools/bounding_box
[inkscape.git] / src / sp-image.cpp
index 6cc3830a7bd1e3555fddd26e34ee156273828612..95e104b7652774de37739cd4266a38ea20e179d1 100644 (file)
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
-#include <libnr/nr-matrix-fns.h>
 
+#include <cstring>
+#include <string>
+#include <libnr/nr-matrix-fns.h>
+#include <libnr/nr-matrix-ops.h>
+#include <libnr/nr-translate-matrix-ops.h>
+#include <libnr/nr-scale-translate-ops.h>
 //#define GDK_PIXBUF_ENABLE_BACKEND 1
 //#include <gdk-pixbuf/gdk-pixbuf-io.h>
 #include "display/nr-arena-image.h"
@@ -231,17 +236,17 @@ void user_read_data( png_structp png_ptr, png_bytep data, png_size_t length )
 //    g_message("things out");
 }
 
-void user_write_data( png_structp png_ptr, png_bytep data, png_size_t length )
+void user_write_data( png_structp /*png_ptr*/, png_bytep /*data*/, png_size_t /*length*/ )
 {
     //g_message( "user_write_data(%d)", length );
 }
 
-void user_flush_data( png_structp png_ptr )
+void user_flush_data( png_structp /*png_ptr*/ )
 {
     //g_message( "user_flush_data" );
 }
 
-GdkPixbuf*  pixbuf_new_from_file( const char *filename, GError **error )
+GdkPixbuf*  pixbuf_new_from_file( const char *filename, GError **/*error*/ )
 {
     GdkPixbuf* buf = NULL;
     PushPull youme;
@@ -973,7 +978,7 @@ sp_image_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
 }
 
 static void
-sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
+sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
 {
        SPImage const &image = *SP_IMAGE(item);
 
@@ -994,7 +999,6 @@ static void
 sp_image_print (SPItem *item, SPPrintContext *ctx)
 {
        SPImage *image;
-       NRMatrix tp, ti, s, t;
        guchar *px;
        int w, h, rs, pixskip;
 
@@ -1009,20 +1013,22 @@ sp_image_print (SPItem *item, SPPrintContext *ctx)
        rs = gdk_pixbuf_get_rowstride (image->pixbuf);
        pixskip = gdk_pixbuf_get_n_channels (image->pixbuf) * gdk_pixbuf_get_bits_per_sample (image->pixbuf) / 8;
 
+    NR::Matrix t;
        if (image->aspect_align == SP_ASPECT_NONE) {
                /* fixme: (Lauris) */
-               nr_matrix_set_translate (&tp, image->x.computed, image->y.computed);
-               nr_matrix_set_scale (&s, image->width.computed, -image->height.computed);
-               nr_matrix_set_translate (&ti, 0.0, -1.0);
+        NR::translate tp = NR::translate(image->x.computed, image->y.computed);
+        NR::scale s = NR::scale(image->width.computed, -image->height.computed);
+        NR::translate ti = NR::translate(0.0, -1.0);
+           t = s * tp;
+           t = ti * t;
        } else { // preserveAspectRatio
-               nr_matrix_set_translate (&tp, image->viewx, image->viewy);
-               nr_matrix_set_scale (&s, image->viewwidth, -image->viewheight);
-               nr_matrix_set_translate (&ti, 0.0, -1.0);
+        NR::translate tp = NR::translate(image->viewx, image->viewy);
+        NR::scale s = NR::scale(image->viewwidth, -image->viewheight);
+        NR::translate ti = NR::translate(0.0, -1.0);
+           t = s * tp;
+           t = ti * t;
        }
 
-       nr_matrix_multiply (&t, &s, &tp);
-       nr_matrix_multiply (&t, &ti, &t);
-
        if (image->aspect_align == SP_ASPECT_NONE)
                sp_print_image_R8G8B8A8_N (ctx, px, w, h, rs, &t, SP_OBJECT_STYLE (item));
        else // preserveAspectRatio
@@ -1054,7 +1060,7 @@ sp_image_description(SPItem *item)
 }
 
 static NRArenaItem *
-sp_image_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags)
+sp_image_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/)
 {
        int pixskip, rs;
        SPImage * image;