recolor_image function can now be used with custom colors

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1477 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2010-08-03 18:44:44 +00:00
parent 6bfe384fb6
commit 968f557511
10 changed files with 63 additions and 6 deletions
+14
View File
@@ -221,6 +221,20 @@ bool RecolorImage::operator == (const GeneratedImage& that) const {
&& color == that2->color;
}
Image RecolorImage2::generate(const Options& opt) const {
Image img = image->generate(opt);
recolor(img, red,green,blue,white);
return img;
}
bool RecolorImage2::operator == (const GeneratedImage& that) const {
const RecolorImage2* that2 = dynamic_cast<const RecolorImage2*>(&that);
return that2 && *image == *that2->image
&& red == that2->red
&& green == that2->green
&& blue == that2->blue
&& white == that2->white;
}
// ----------------------------------------------------------------------------- : FlipImage
Image FlipImageHorizontal::generate(const Options& opt) const {
+11
View File
@@ -227,6 +227,17 @@ class RecolorImage : public SimpleFilterImage {
private:
Color color;
};
/// Recolor an image, with custom colors
class RecolorImage2 : public SimpleFilterImage {
public:
inline RecolorImage2(const GeneratedImageP& image, Color red, Color green, Color blue, Color white)
: SimpleFilterImage(image), red(red), green(green), blue(blue), white(white)
{}
virtual Image generate(const Options& opt) const;
virtual bool operator == (const GeneratedImage& that) const;
private:
Color red,green,blue,white;
};
// ----------------------------------------------------------------------------- : FlipImage
+9 -2
View File
@@ -93,8 +93,15 @@ SCRIPT_FUNCTION(invert_image) {
SCRIPT_FUNCTION(recolor_image) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(Color, color);
return intrusive(new RecolorImage(input,color));
SCRIPT_OPTIONAL_PARAM(Color, red) {
SCRIPT_PARAM(Color, green);
SCRIPT_PARAM(Color, blue);
SCRIPT_PARAM_DEFAULT(Color, white, *wxWHITE);
return intrusive(new RecolorImage2(input,red,green,blue,white));
} else {
SCRIPT_PARAM(Color, color);
return intrusive(new RecolorImage(input,color));
}
}
SCRIPT_FUNCTION(enlarge) {