diff --git a/pandatool/src/imageprogs/imageTrans.cxx b/pandatool/src/imageprogs/imageTrans.cxx index 47cd0c6851..58e1329d1c 100644 --- a/pandatool/src/imageprogs/imageTrans.cxx +++ b/pandatool/src/imageprogs/imageTrans.cxx @@ -43,6 +43,26 @@ ImageTrans() : ImageFilter(true) { "Apply the indicated color scale to each pixel of the image.", &ImageTrans::dispatch_color, &_has_color_scale, &_color_scale); + add_option + ("flip", "", 50, + "Flip the image vertically.", + &ImageTrans::dispatch_none, &_flip); + + add_option + ("mirror", "", 50, + "Reverse the image horizontally.", + &ImageTrans::dispatch_none, &_mirror); + + add_option + ("cw", "", 50, + "Rotate the image 90 degrees clockwise.", + &ImageTrans::dispatch_none, &_cw); + + add_option + ("ccw", "", 50, + "Rotate the image 90 degrees counter-clockwise.", + &ImageTrans::dispatch_none, &_ccw); + _channels = C_default; _color_scale.set(1.0f, 1.0f, 1.0f, 1.0f); } @@ -109,6 +129,19 @@ run() { } } + bool transpose = false; + if (_cw) { + _flip = !_flip; + transpose = !transpose; + } + if (_ccw) { + _mirror = !_mirror; + transpose = !transpose; + } + if (_flip || _mirror || transpose) { + _image.flip(_mirror, _flip, transpose); + } + write_image(); } diff --git a/pandatool/src/imageprogs/imageTrans.h b/pandatool/src/imageprogs/imageTrans.h index a1c106a39b..b3a5d00876 100644 --- a/pandatool/src/imageprogs/imageTrans.h +++ b/pandatool/src/imageprogs/imageTrans.h @@ -50,6 +50,7 @@ private: Channels _channels; LColor _color_scale; bool _has_color_scale; + bool _flip, _mirror, _cw, _ccw; }; #endif