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
This commit is contained in:
Adrià Arrufat 2024-03-04 21:30:18 +09:00 committed by GitHub
parent 405536051b
commit c7ba757bc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 80 additions and 3 deletions

View File

@ -75,6 +75,21 @@ namespace dlib
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

View File

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

View File

@ -105,6 +105,22 @@ namespace dlib
- 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<
typename image_type
>

View File

@ -156,6 +156,8 @@ namespace dlib
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; }
unsigned int png_loader::bit_depth () const {return bit_depth_;}
long png_loader::nr() const { return height; }
long png_loader::nc() const { return width; }
// ----------------------------------------------------------------------------------------

View File

@ -36,6 +36,8 @@ namespace dlib
bool is_rgb() const;
bool is_rgba() const;
unsigned int bit_depth () const;
long nr() const;
long nc() const;
template<class image_type>
void get_image( image_type& img) const

View File

@ -145,6 +145,22 @@ namespace dlib
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<
typename image_type
>

View File

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

View File

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

View File

@ -82,6 +82,22 @@ namespace dlib
- 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<
typename image_type
>