From 2ed0befbad3370727a1ea2c122ed1da42e69af32 Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Thu, 10 Jul 2003 11:55:01 +0000
Subject: added rotate

---
 src/FbTk/FbPixmap.cc | 37 ++++++++++++++++++++++++++++++++++++-
 src/FbTk/FbPixmap.hh |  4 +++-
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc
index a05e287..75ab8d7 100644
--- a/src/FbTk/FbPixmap.cc
+++ b/src/FbTk/FbPixmap.cc
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: FbPixmap.cc,v 1.4 2003/04/29 08:53:24 fluxgen Exp $
+// $Id: FbPixmap.cc,v 1.5 2003/07/10 11:55:01 fluxgen Exp $
 
 #include "FbPixmap.hh"
 #include "App.hh"
@@ -132,6 +132,41 @@ void FbPixmap::copy(const FbPixmap &the_copy) {
     }
 }
 
+void FbPixmap::rotate() {
+
+    Display *dpy = FbTk::App::instance()->display();
+
+    // make an image copy
+    XImage *src_image = XGetImage(dpy, drawable(),
+                                  0, 0, // pos
+                                  width(), height(), // size
+                                  ~0, // plane mask
+                                  ZPixmap); // format
+    // reverse height/width for new pixmap
+    FbPixmap new_pm(drawable(), height(), width(), depth());
+
+    GC gc = XCreateGC(dpy, drawable(), 0, 0);
+
+    // copy new area
+    for (int y = 0; y < height(); ++y) {
+        for (int x = 0; x < width(); ++x) {
+            XSetForeground(dpy, gc, XGetPixel(src_image, x, y));
+            // revers coordinates
+            XDrawPoint(dpy, new_pm.drawable(), gc, y, x);
+        }
+    }
+    XFreeGC(dpy, gc);
+
+    XDestroyImage(src_image);
+    // free old pixmap and set new from new_pm
+    free();
+
+    m_width = new_pm.width();
+    m_height = new_pm.height();
+    m_depth = new_pm.depth();
+    m_pm = new_pm.release();
+}
+
 void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) {
     if (drawable() == 0 || 
         (dest_width == width() && dest_height == height()))
diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh
index 94d37de..787c06f 100644
--- a/src/FbTk/FbPixmap.hh
+++ b/src/FbTk/FbPixmap.hh
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: FbPixmap.hh,v 1.4 2003/04/29 08:52:51 fluxgen Exp $
+// $Id: FbPixmap.hh,v 1.5 2003/07/10 11:55:01 fluxgen Exp $
 
 #ifndef FBTK_FBPIXMAP_HH
 #define FBTK_FBPIXMAP_HH
@@ -45,6 +45,8 @@ public:
     ~FbPixmap();
 
     void copy(const FbPixmap &the_copy);
+    /// rotates the pixmap 90 deg, not implemented!
+    void rotate();
     /// scales the pixmap to specified size
     void scale(unsigned int width, unsigned int height);
     /// drops pixmap and returns it
-- 
cgit v0.11.2