21 #ifndef GR_IMAGE_TYPE__H
22 #define GR_IMAGE_TYPE__H
49 const char * c_str()
const {
return s ; }
50 std::string str()
const ;
63 explicit ImageType(
const std::vector<char> & ) ;
74 ImageType(
const unsigned char * p ,
size_t n ) ;
77 explicit ImageType(
const std::string & ) ;
105 bool matches(
const std::string &
str )
const ;
108 std::string
str()
const ;
114 std::string
simple()
const ;
138 size_t size()
const ;
159 enum Type { t_invalid , t_jpeg , t_png , t_raw , t_pnm } ;
160 ImageType( Type type_ ,
int dx_ ,
int dy_ ,
int channels_ ) ;
161 static Type typeFromSignature(
const unsigned char * ,
size_t ) ;
162 void init( std::istream & ) ;
163 void init(
const unsigned char * p ,
size_t n ) ;
164 void init( Type ,
int ,
int ,
int ) ;
165 void setsimple( String & )
const ;
177 std::ostream & operator<<( std::ostream & stream ,
const ImageType & s )
179 s.streamOut( stream ) ;
bool isRaw() const
Returns true if a raw image type.
bool isJpeg() const
Returns true if a jpeg image type.
bool operator<(const ImageType &) const
Comparison operator.
int channels() const
Returns the number of channels.
static ImageType jpeg(int dx, int dy, int channels=3)
Factory function for a jpeg image type.
An encapsulation of image type, including width, height and number of channels, with support for a st...
Vectors ImageBuffer
An ImageBuffer is used to hold raw image data, typically in more than one chunk.
String & set(String &out) const
Returns str() by reference.
static ImageType raw(int dx, int dy, int channels)
Factory function for a raw image type.
std::string str() const
Returns the image type string (including the size parameter).
size_t size() const
Returns the product of dx, dy and channels.
bool valid() const
Returns true if valid.
bool isPng() const
Returns true if a png image type.
int dy() const
Returns the image height.
void streamOut(std::ostream &) const
Used by op<<().
size_t rowsize() const
Returns the product of dx and channels.
bool matches(const std::string &str) const
Returns true if this type matches the given type (including size decorations).
int dx() const
Returns the image width.
std::string simple() const
Returns the basic image type string, excluding the size parameter.
bool operator!=(const ImageType &) const
Comparison operator.
ImageType()
Default constructor for an in-valid() image type with dimensions of zero.
A small-string class used for stringised Gr::ImageType instances.
bool operator==(const ImageType &) const
Comparison operator.
bool isPnm() const
Returns true if a pnm image type.
static ImageType png(int dx, int dy, int channels=3)
Factory function for a png image type.