1 // Copyright (C) 2014 Davis E. King (davis@dlib.net) 2 // License: Boost Software License See LICENSE.txt for the full license. 3 #ifndef DLIB_ARRAY2D_GENERIC_iMAGE_Hh_ 4 #define DLIB_ARRAY2D_GENERIC_iMAGE_Hh_ 5 6 #include "array2d_kernel.h" 7 #include "../image_processing/generic_image.h" 8 9 namespace dlib 10 { 11 template <typename T, typename mm> 12 struct image_traits<array2d<T,mm> > 13 { 14 typedef T pixel_type; 15 }; 16 template <typename T, typename mm> 17 struct image_traits<const array2d<T,mm> > 18 { 19 typedef T pixel_type; 20 }; 21 22 template <typename T, typename mm> 23 inline long num_rows( const array2d<T,mm>& img) { return img.nr(); } 24 template <typename T, typename mm> 25 inline long num_columns( const array2d<T,mm>& img) { return img.nc(); } 26 27 template <typename T, typename mm> 28 inline void set_image_size( 29 array2d<T,mm>& img, 30 long rows, 31 long cols 32 ) { img.set_size(rows,cols); } 33 34 template <typename T, typename mm> 35 inline void* image_data( 36 array2d<T,mm>& img 37 ) 38 { 39 if (img.size() != 0) 40 return &img[0][0]; 41 else 42 return 0; 43 } 44 45 template <typename T, typename mm> 46 inline const void* image_data( 47 const array2d<T,mm>& img 48 ) 49 { 50 if (img.size() != 0) 51 return &img[0][0]; 52 else 53 return 0; 54 } 55 56 template <typename T, typename mm> 57 inline long width_step( 58 const array2d<T,mm>& img 59 ) 60 { 61 return img.width_step(); 62 } 63 64 } 65 66 #endif // DLIB_ARRAY2D_GENERIC_iMAGE_Hh_ 67 68