[niepce] Cosmetic enhancement to the canvas.



commit e796ca91d93c2aac9d36950a79666ca6eb6ddf35
Author: Hubert Figuiere <hub figuiere net>
Date:   Fri May 15 02:13:32 2009 -0400

    Cosmetic enhancement to the canvas.
---
 ChangeLog                                   |    7 ++++++
 src/ncr/image.cpp                           |    2 +-
 src/ncr/image.hpp                           |    5 ++-
 src/niepce/modules/darkroom/imagecanvas.cpp |   32 +++++++++++++++++++++-----
 4 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d022ca..0a3ec83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-15  Hubert Figuiere  <hub figuiere net>
+
+	* src/ncr/image.cpp
+	* src/ncr/image.hpp
+	* src/niepce/modules/darkroom/imagecanvas.cpp:
+	Cosmetic enhancement to the canvas.
+
 2009-05-14  Hubert Figuiere  <hub figuiere net>
 
 	* README:
diff --git a/src/ncr/image.cpp b/src/ncr/image.cpp
index d04ac06..a4722fc 100644
--- a/src/ncr/image.cpp
+++ b/src/ncr/image.cpp
@@ -181,7 +181,7 @@ void Image::reload(const std::string & p, bool is_raw,
     signal_update();
 }
 
-void Image::set_scale(double scale)
+void Image::set_output_scale(double scale)
 {
     DBG_OUT("scale %f", scale);
     priv->m_scale->set("x", scale);
diff --git a/src/ncr/image.hpp b/src/ncr/image.hpp
index 7cb2a90..89ce5cc 100644
--- a/src/ncr/image.hpp
+++ b/src/ncr/image.hpp
@@ -30,7 +30,7 @@
 namespace ncr {
 
 class Image 
-    : public std::tr1::enable_shared_from_this<Image>
+//    : public std::tr1::enable_shared_from_this<Image>
 {
 public:
     typedef std::tr1::shared_ptr<Image> Ptr;
@@ -51,7 +51,8 @@ public:
 
     void reload(const std::string & p, bool is_raw,
         int orientation);
-    void set_scale(double scale);
+    /** set the output scale */
+    void set_output_scale(double scale);
 
     void set_tilt(double angle);
     void set_color_temp(int temp);
diff --git a/src/niepce/modules/darkroom/imagecanvas.cpp b/src/niepce/modules/darkroom/imagecanvas.cpp
index 1c5f8e0..024625a 100644
--- a/src/niepce/modules/darkroom/imagecanvas.cpp
+++ b/src/niepce/modules/darkroom/imagecanvas.cpp
@@ -28,6 +28,12 @@
 
 namespace darkroom {
 
+
+
+#define IMAGE_INSET 6
+#define SHADOW_OFFSET 3
+
+
 ImageCanvas::ImageCanvas()
     : m_need_redisplay(true),
       m_zoom_mode(ZOOM_MODE_FIT)
@@ -54,8 +60,8 @@ void ImageCanvas::on_image_reloaded()
 double ImageCanvas::_calc_image_scale(int img_w, int img_h)
 {
     double b_w, b_h;
-    b_w = get_width();
-    b_h = get_height();
+    b_w = get_width() - (IMAGE_INSET * 2);
+    b_h = get_height() - (IMAGE_INSET * 2);
 
     double scale_w = b_w / img_w;
     double scale_h = b_h / img_h;
@@ -95,7 +101,7 @@ bool ImageCanvas::on_expose_event(GdkEventExpose *ev)
         DBG_OUT("image w = %d ; h = %d", img_w, img_h);
         double scale = _calc_image_scale(img_w, img_h);
         DBG_OUT("scale = %f", scale);
-        m_image->set_scale(scale);
+        m_image->set_output_scale(scale);
 
 
         // query the image.
@@ -113,6 +119,9 @@ bool ImageCanvas::on_expose_event(GdkEventExpose *ev)
         Cairo::RefPtr<Cairo::Context> sc 
             = Cairo::Context::create(m_backingstore);
 
+
+//        sc->set_antialias(Cairo::ANTIALIAS_NONE);
+
         // paint the background
         sc->rectangle(0, 0, canvas_w, canvas_h);
         Gdk::Cairo::set_source_color(sc, 
@@ -120,14 +129,25 @@ bool ImageCanvas::on_expose_event(GdkEventExpose *ev)
         sc->fill();
 
 
-
-        double x = (canvas_w - (img_w*scale)) / 2;
-        double y = (canvas_h - (img_h*scale)) / 2;
+        double out_w = (img_w * scale);
+        double out_h = (img_h * scale);
+        double x = (canvas_w - out_w) / 2;
+        double y = (canvas_h - out_h) / 2;
         DBG_OUT("x = %f ; y = %f", x, y);
 
+        sc->rectangle(x + SHADOW_OFFSET, y + SHADOW_OFFSET + 1, out_w, out_h);
+        sc->set_source_rgb(0.0, 0.0, 0.0);
+        sc->fill();
+
         sc->set_source(img_s, x, y);
         sc->paint();
 
+//        sc->set_source_rgb(1.0, 1.0, 1.0);
+//        sc->set_line_width(1.0);
+//        sc->rectangle(x, y, out_w, out_h);
+//        sc->stroke();
+		
+
         m_need_redisplay = false;
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]