Code

r16895@shi: ted | 2007-10-30 09:35:24 -0700
authorgouldtj <gouldtj@users.sourceforge.net>
Tue, 30 Oct 2007 19:30:20 +0000 (19:30 +0000)
committergouldtj <gouldtj@users.sourceforge.net>
Tue, 30 Oct 2007 19:30:20 +0000 (19:30 +0000)
 Adding in Chris' downsample patch.

src/extension/init.cpp
src/extension/internal/Makefile_insert
src/extension/internal/bitmap/sample.cpp [new file with mode: 0644]
src/extension/internal/bitmap/sample.h [new file with mode: 0644]

index 8c2be3e283ab9b5a4fbac86e5b1214c4b4cdd0e8..3a9f1e9aadcee8b822d8b9deeda7f3f6e8bc3205 100644 (file)
@@ -85,6 +85,7 @@
 #include "internal/bitmap/opacity.h"
 #include "internal/bitmap/raise.h"
 #include "internal/bitmap/reduceNoise.h"
+#include "internal/bitmap/sample.h"
 #include "internal/bitmap/shade.h"
 #include "internal/bitmap/sharpen.h"
 #include "internal/bitmap/solarize.h"
@@ -214,6 +215,7 @@ init()
     Internal::Bitmap::Opacity::init();
     Internal::Bitmap::Raise::init();
     Internal::Bitmap::ReduceNoise::init();
+    Internal::Bitmap::Sample::init();
     Internal::Bitmap::Shade::init();
     Internal::Bitmap::Sharpen::init();
     Internal::Bitmap::Solarize::init();
index dc2d9bbf37816c234e319b051b8be047033b808c..87d76a3ecff1665567d163fefb44c5f802fe6f61 100644 (file)
@@ -6,17 +6,17 @@ extension/internal/clean:
        rm -f extension/internal/libinternal.a $(extension_internal_libinternal_OBJECTS)
 
 if USE_IMAGE_MAGICK
-extension_internal_image_magick_sources =      \
+extension_internal_image_magick_sources =                      \
        extension/internal/bitmap/imagemagick.cpp               \
        extension/internal/bitmap/imagemagick.h                 \
-       extension/internal/bitmap/adaptiveThreshold.cpp \
-       extension/internal/bitmap/adaptiveThreshold.h   \
+       extension/internal/bitmap/adaptiveThreshold.cpp         \
+       extension/internal/bitmap/adaptiveThreshold.h           \
        extension/internal/bitmap/addNoise.cpp                  \
        extension/internal/bitmap/addNoise.h                    \
-       extension/internal/bitmap/blur.cpp                              \
-       extension/internal/bitmap/blur.h                                \
+       extension/internal/bitmap/blur.cpp                      \
+       extension/internal/bitmap/blur.h                        \
        extension/internal/bitmap/channel.cpp                   \
-       extension/internal/bitmap/channel.h                             \
+       extension/internal/bitmap/channel.h                     \
        extension/internal/bitmap/charcoal.cpp                  \
        extension/internal/bitmap/charcoal.h                    \
        extension/internal/bitmap/colorize.cpp                  \
@@ -27,20 +27,20 @@ extension_internal_image_magick_sources =   \
        extension/internal/bitmap/cycleColormap.h               \
        extension/internal/bitmap/despeckle.cpp                 \
        extension/internal/bitmap/despeckle.h                   \
-       extension/internal/bitmap/edge.cpp                              \
-       extension/internal/bitmap/edge.h                                \
+       extension/internal/bitmap/edge.cpp                      \
+       extension/internal/bitmap/edge.h                        \
        extension/internal/bitmap/emboss.cpp                    \
-       extension/internal/bitmap/emboss.h                              \
+       extension/internal/bitmap/emboss.h                      \
        extension/internal/bitmap/enhance.cpp                   \
-       extension/internal/bitmap/enhance.h                             \
+       extension/internal/bitmap/enhance.h                     \
        extension/internal/bitmap/equalize.cpp                  \
        extension/internal/bitmap/equalize.h                    \
        extension/internal/bitmap/gaussianBlur.cpp              \
        extension/internal/bitmap/gaussianBlur.h                \
        extension/internal/bitmap/implode.cpp                   \
-       extension/internal/bitmap/implode.h                             \
-       extension/internal/bitmap/level.cpp                             \
-       extension/internal/bitmap/level.h                               \
+       extension/internal/bitmap/implode.h                     \
+       extension/internal/bitmap/level.cpp                     \
+       extension/internal/bitmap/level.h                       \
        extension/internal/bitmap/levelChannel.cpp              \
        extension/internal/bitmap/levelChannel.h                \
        extension/internal/bitmap/medianFilter.cpp              \
@@ -48,32 +48,34 @@ extension_internal_image_magick_sources =   \
        extension/internal/bitmap/modulate.cpp                  \
        extension/internal/bitmap/modulate.h                    \
        extension/internal/bitmap/negate.cpp                    \
-       extension/internal/bitmap/negate.h                              \
+       extension/internal/bitmap/negate.h                      \
        extension/internal/bitmap/normalize.cpp                 \
        extension/internal/bitmap/normalize.h                   \
        extension/internal/bitmap/oilPaint.cpp                  \
        extension/internal/bitmap/oilPaint.h                    \
        extension/internal/bitmap/opacity.cpp                   \
-       extension/internal/bitmap/opacity.h                             \
-       extension/internal/bitmap/raise.cpp                             \
-       extension/internal/bitmap/raise.h                               \
+       extension/internal/bitmap/opacity.h                     \
+       extension/internal/bitmap/raise.cpp                     \
+       extension/internal/bitmap/raise.h                       \
        extension/internal/bitmap/reduceNoise.cpp               \
        extension/internal/bitmap/reduceNoise.h                 \
-       extension/internal/bitmap/shade.cpp                             \
-       extension/internal/bitmap/shade.h                               \
+       extension/internal/bitmap/sample.cpp                    \
+       extension/internal/bitmap/sample.h                      \
+       extension/internal/bitmap/shade.cpp                     \
+       extension/internal/bitmap/shade.h                       \
        extension/internal/bitmap/sharpen.cpp                   \
-       extension/internal/bitmap/sharpen.h                             \
+       extension/internal/bitmap/sharpen.h                     \
        extension/internal/bitmap/solarize.cpp                  \
        extension/internal/bitmap/solarize.h                    \
        extension/internal/bitmap/spread.cpp                    \
-       extension/internal/bitmap/spread.h                              \
-       extension/internal/bitmap/swirl.cpp                             \
-       extension/internal/bitmap/swirl.h                               \
+       extension/internal/bitmap/spread.h                      \
+       extension/internal/bitmap/swirl.cpp                     \
+       extension/internal/bitmap/swirl.h                       \
        extension/internal/bitmap/threshold.cpp                 \
        extension/internal/bitmap/threshold.h                   \
        extension/internal/bitmap/unsharpmask.cpp               \
        extension/internal/bitmap/unsharpmask.h                 \
-       extension/internal/bitmap/wave.cpp                              \
+       extension/internal/bitmap/wave.cpp                      \
        extension/internal/bitmap/wave.h
 endif
 
diff --git a/src/extension/internal/bitmap/sample.cpp b/src/extension/internal/bitmap/sample.cpp
new file mode 100644 (file)
index 0000000..9c24543
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "sample.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Sample::applyEffect(Magick::Image* image) {
+       Magick::Geometry geometry(_width, _height, 0, 0);
+       image->sample(geometry);
+}
+
+void
+Sample::refreshParameters(Inkscape::Extension::Effect* module) {
+       _width = module->get_param_int("width");
+       _height = module->get_param_int("height");
+}
+
+#include "../clear-n_.h"
+
+void
+Sample::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Sample") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.sample</id>\n"
+                       "<param name=\"width\" gui-text=\"" N_("Width") "\" type=\"int\" min=\"0\" max=\"6400\">100</param>\n"
+                       "<param name=\"height\" gui-text=\"" N_("Height") "\" type=\"int\" min=\"0\" max=\"6400\">100</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Alter the resolution of selected image by resizing it by given dimensions.") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Sample());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/sample.h b/src/extension/internal/bitmap/sample.h
new file mode 100644 (file)
index 0000000..a378229
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Sample : public ImageMagick
+{
+private:
+       int _width;
+       int _height;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */