Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ipicture_painter

The ipicture_painter implements the COM IPicture-Interface which allows loading bmp, jpg and gif image files. The class draws the image on a background_wnd. If the drawing-rectangle of the painter is smaller than the image the image will be clipped. Copying an ipicture is a non-expensive operation - it's just a call to AddRef()!

namespace win32 { namespace gui {

     namespace detail {

          // base of the ipicture_painters. note how the exception is specified for the Derived class ;-)
          template <class Derived>
          struct ipicture_painter_base : painter_base
          {    
               typedef ipicture_painter_base_impl::param0 param0;

               // exceptions
               typedef bg_wnd::general_exception<Derived, 0> file_not_found;
               
               void load_file(const std::string& file_name);
               const bg_wnd::ipicture& get_ipicture() const;
          };

     }    // namespace detail

     // ========================================================================================================= //

     class ipicture_painter : public detail::ipicture_painter_base<ipicture_painter>
     {
     public:
          // c'tor
          ipicture_painter(const std::string& file_name = "");             

          // virtual functions of painter_base
          ipicture_painter* clone() const;
          void draw(HDC hDC, int cx, int cy);     
     };

} }  // namespace win32::gui

Note:


Example:
add_painter<ipicture_painter> ("c:\\img1.jpg");

The result is as follows

ipicture_painter.jpg

tile_ipicture_painter

The tile_ipicture_painter does the same as the ipicture_painter with the difference that the image loaded from the file will be displayed in tiles. You can optionally set the size of the tiles.

namespace win32 { namespace gui {

     class tile_ipicture_painter : public detail::ipicture_painter_base<tile_ipicture_painter>
     {
     public:
          typedef SIZE param1;

          // c'tor
          tile_ipicture_painter(const std::string& file_name = "");             
          tile_ipicture_painter(const std::string& file_name, SIZE tile_size);
          
          // virtual functions of painter_base
          tile_ipicture_painter* clone() const;   
          void draw(HDC hDC, int cx, int cy);          

          // own functions
          void tile_size(SIZE tile_size);
          SIZE tile_size() const;
     };

} }  // namespace win32::gui

Note:


Example:
const SIZE tile_size = ...;
add_painter<tile_ipicture_painter> ("c:\\img1.jpg", tile_size);

The result is as follows
tile_ipicture_painter_100_100.jpg
tile_ipicture_painter_0_0.jpg
tile_size = { 100, 100 } tile_size = { 0, 0 } (determine resource size)



by Steven Weiss. You can contact me at steven11@gmx.de.