add nr and nc methods to jpeg, png and webp loaders (#2920)

* add nr and nc methods to jpeg, png and webp loaders

* Oops, forgot to declare methods in jpeg_loader.h
pull/2923/head
Adrià Arrufat 7 months ago committed by GitHub
parent 405536051b
commit c7ba757bc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -75,6 +75,21 @@ namespace dlib
return (output_components_ == 4); return (output_components_ == 4);
} }
// ----------------------------------------------------------------------------------------
long jpeg_loader::nr() const
{
return static_cast<long>(height_);
}
// ----------------------------------------------------------------------------------------
long jpeg_loader::nc() const
{
return static_cast<long>(width_);
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
struct jpeg_loader_error_mgr struct jpeg_loader_error_mgr

@ -26,6 +26,8 @@ namespace dlib
bool is_gray() const; bool is_gray() const;
bool is_rgb() const; bool is_rgb() const;
bool is_rgba() const; bool is_rgba() const;
long nr() const;
long nc() const;
template<typename T> template<typename T>
void get_image( T& t_) const void get_image( T& t_) const

@ -105,6 +105,22 @@ namespace dlib
- returns false - returns false
!*/ !*/
long nr (
) const;
/*!
ensures
- returns the number of rows (height) of the image contained by this
object.
!*/
long nc (
) const;
/*!
ensures
- returns the number of colums (width) of the image contained by this
object.
!*/
template< template<
typename image_type typename image_type
> >

@ -156,6 +156,8 @@ namespace dlib
bool png_loader::is_rgb() const { return color_type == PNG_COLOR_TYPE_RGB; } bool png_loader::is_rgb() const { return color_type == PNG_COLOR_TYPE_RGB; }
bool png_loader::is_rgba() const { return color_type == PNG_COLOR_TYPE_RGB_ALPHA; } bool png_loader::is_rgba() const { return color_type == PNG_COLOR_TYPE_RGB_ALPHA; }
unsigned int png_loader::bit_depth () const {return bit_depth_;} unsigned int png_loader::bit_depth () const {return bit_depth_;}
long png_loader::nr() const { return height; }
long png_loader::nc() const { return width; }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
@ -163,4 +165,4 @@ namespace dlib
#endif // DLIB_PNG_SUPPORT #endif // DLIB_PNG_SUPPORT
#endif // DLIB_PNG_LOADER_CPp_ #endif // DLIB_PNG_LOADER_CPp_

@ -36,6 +36,8 @@ namespace dlib
bool is_rgb() const; bool is_rgb() const;
bool is_rgba() const; bool is_rgba() const;
unsigned int bit_depth () const; unsigned int bit_depth () const;
long nr() const;
long nc() const;
template<class image_type> template<class image_type>
void get_image( image_type& img) const void get_image( image_type& img) const
@ -193,4 +195,4 @@ namespace dlib
#include "png_loader.cpp" #include "png_loader.cpp"
#endif #endif
#endif // DLIB_PNG_IMPORT #endif // DLIB_PNG_IMPORT

@ -145,6 +145,22 @@ namespace dlib
object. The possible values are 8 or 16. object. The possible values are 8 or 16.
!*/ !*/
long nr (
) const;
/*!
ensures
- returns the number of rows (height) of the image contained by this
object.
!*/
long nc (
) const;
/*!
ensures
- returns the number of colums (width) of the image contained by this
object.
!*/
template< template<
typename image_type typename image_type
> >
@ -220,4 +236,4 @@ namespace dlib
} }
#endif // DLIB_PNG_IMPORT_ABSTRACT #endif // DLIB_PNG_IMPORT_ABSTRACT

@ -62,6 +62,11 @@ namespace dlib
get_info(); get_info();
} }
// ----------------------------------------------------------------------------------------
long webp_loader::nr() const { return height_; }
long webp_loader::nc() const { return width_; }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
void webp_loader::get_info() void webp_loader::get_info()

@ -23,6 +23,9 @@ namespace dlib
webp_loader(const dlib::file& f); webp_loader(const dlib::file& f);
webp_loader(const unsigned char* imgbuffer, size_t buffersize); webp_loader(const unsigned char* imgbuffer, size_t buffersize);
long nr() const;
long nc() const;
template<typename image_type> template<typename image_type>
void get_image(image_type& image) const void get_image(image_type& image) const
{ {

@ -82,6 +82,22 @@ namespace dlib
- all resources associated with *this has been released - all resources associated with *this has been released
!*/ !*/
long nr (
) const;
/*!
ensures
- returns the number of rows (height) of the image contained by this
object.
!*/
long nc (
) const;
/*!
ensures
- returns the number of colums (width) of the image contained by this
object.
!*/
template< template<
typename image_type typename image_type
> >

Loading…
Cancel
Save