From f432c9671a39ca43063146dc34a8bd8c0e304aef Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 22 Mar 2009 18:24:59 +0000 Subject: [PATCH] Improved the image_window a bit. --HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402967 --- dlib/gui_widgets/widgets.h | 8 +++++++- dlib/gui_widgets/widgets_abstract.h | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/dlib/gui_widgets/widgets.h b/dlib/gui_widgets/widgets.h index c4c52be3a..d8e8784ae 100644 --- a/dlib/gui_widgets/widgets.h +++ b/dlib/gui_widgets/widgets.h @@ -3159,6 +3159,11 @@ namespace dlib image_window( ); + template < typename image_type > + image_window( + const image_type& img + ) : gui_img(*this) { set_image(img); show(); } + ~image_window( ); @@ -3167,11 +3172,12 @@ namespace dlib const image_type& img ) { + const unsigned long padding = scrollable_region_style_default().get_border_size(); auto_mutex M(wm); gui_img.set_image(img); // set the size of this window to match the size of the input image - set_size(img.nc(),img.nr()); + set_size(img.nc()+padding*2,img.nr()+padding*2); // call this to make sure everything else is setup properly on_window_resized(); diff --git a/dlib/gui_widgets/widgets_abstract.h b/dlib/gui_widgets/widgets_abstract.h index a8c32917f..12589f280 100644 --- a/dlib/gui_widgets/widgets_abstract.h +++ b/dlib/gui_widgets/widgets_abstract.h @@ -2234,6 +2234,19 @@ namespace dlib - this object is properly initialized !*/ + template + image_window( + const image_type& img + ); + /*! + requires + - image_type == an implementation of array2d/array2d_kernel_abstract.h + - pixel_traits must be defined + ensures + - this object is properly initialized + - #*this window is now displaying the given image img. + !*/ + ~image_window( ); /*! @@ -2241,7 +2254,7 @@ namespace dlib - any resources associated with this object have been released !*/ - template < typename image_type > + template void set_image ( const image_type& img ); @@ -2250,7 +2263,7 @@ namespace dlib - image_type == an implementation of array2d/array2d_kernel_abstract.h - pixel_traits must be defined ensures - - #*this window is now displaying the given image new_img. + - #*this window is now displaying the given image img. !*/ void add_overlay (