From d9f17a17c3aed77392cbe0a07ff1e16d8e0ed561 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Wed, 10 Sep 2003 21:37:05 +0000 Subject: cleaning --- src/FbTk/FbPixmap.cc | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 5be9e7b..0ea6aa1 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -19,10 +19,11 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.cc,v 1.7 2003/08/12 00:25:23 fluxgen Exp $ +// $Id: FbPixmap.cc,v 1.8 2003/09/10 21:37:05 fluxgen Exp $ #include "FbPixmap.hh" #include "App.hh" +#include "GContext.hh" #include #include @@ -115,20 +116,14 @@ void FbPixmap::copy(const FbPixmap &the_copy) { if (drawable()) { Display *dpy = FbTk::App::instance()->display(); - GC temp_gc = XCreateGC(dpy, - drawable(), - 0, 0); - + GContext gc(drawable()); + copyArea(the_copy.drawable(), - temp_gc, + gc.gc(), 0, 0, 0, 0, width(), height()); - - XFreeGC(dpy, temp_gc); - } - } } @@ -178,17 +173,16 @@ void FbPixmap::rotate() { // reverse height/width for new pixmap FbPixmap new_pm(drawable(), height(), width(), depth()); - GC gc = XCreateGC(dpy, drawable(), 0, 0); + GContext gc(drawable()); // 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)); + gc.setForeground(XGetPixel(src_image, x, y)); // revers coordinates - XDrawPoint(dpy, new_pm.drawable(), gc, y, x); + XDrawPoint(dpy, new_pm.drawable(), gc.gc(), y, x); } } - XFreeGC(dpy, gc); XDestroyImage(src_image); // free old pixmap and set new from new_pm @@ -218,8 +212,7 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) { // create new pixmap with dest size FbPixmap new_pm(drawable(), dest_width, dest_height, depth()); - GC gc = XCreateGC(dpy, drawable(), 0, 0); - + GContext gc(drawable()); // calc zoom float zoom_x = static_cast(width())/static_cast(dest_width); float zoom_y = static_cast(height())/static_cast(dest_height); @@ -229,16 +222,13 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) { for (int tx=0; tx(src_x), - static_cast(src_y))); - XDrawPoint(dpy, new_pm.drawable(), gc, tx, ty); - + gc.setForeground(XGetPixel(src_image, + static_cast(src_x), + static_cast(src_y))); + XDrawPoint(dpy, new_pm.drawable(), gc.gc(), tx, ty); } } - XFreeGC(dpy, gc); - XDestroyImage(src_image); // free old pixmap and set new from new_pm @@ -250,6 +240,11 @@ void FbPixmap::scale(unsigned int dest_width, unsigned int dest_height) { m_pm = new_pm.release(); } +void FbPixmap::resize(unsigned int width, unsigned int height) { + FbPixmap pm(drawable(), width, height, depth()); + *this = pm.release(); +} + Pixmap FbPixmap::release() { Pixmap ret = m_pm; m_pm = 0; -- cgit v0.11.2