Kaynağa Gözat

flip, cw, ccw

David Rose 13 yıl önce
ebeveyn
işleme
93743e250d

+ 33 - 0
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();
 }
 

+ 1 - 0
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