Code

Patch from codedread. Prevents rendering of title/desc/metadata elements in text...
[inkscape.git] / src / display / pixblock-scaler.cpp
index ddb4c4ee2652a5a53f4cb374a9be910f510167cf..39c82daf6ed9ba5808f70514afd1b85b4c6efacc 100644 (file)
@@ -17,6 +17,7 @@ using std::floor;
 
 #include "display/nr-filter-utils.h"
 #include "libnr/nr-pixblock.h"
+#include "libnr/nr-blit.h"
 
 namespace NR {
 
@@ -95,6 +96,15 @@ static void scale_bicubic_rgba(NRPixBlock *to, NRPixBlock *from)
         return;
     }
 
+    bool free_from_on_exit = false;
+    if (from->mode != to->mode){
+        NRPixBlock *o_from = from;
+        from = new NRPixBlock;
+        nr_pixblock_setup_fast(from, to->mode, o_from->area.x0, o_from->area.y0, o_from->area.x1, o_from->area.y1, false);
+        nr_blit_pixblock_pixblock(from, o_from);
+        free_from_on_exit = true;
+    }
+
     // Precalculate sizes of source and destination pixblocks
     int from_width = from->area.x1 - from->area.x0;
     int from_height = from->area.y1 - from->area.y0;
@@ -190,6 +200,11 @@ static void scale_bicubic_rgba(NRPixBlock *to, NRPixBlock *from)
             }
         }
     }
+    if (free_from_on_exit) {
+        nr_pixblock_release(from);
+        delete from;
+    }
+
 }
 
 void scale_bicubic_alpha(NRPixBlock *to, NRPixBlock *from)