CMSC23700 Common Code Library
Support code for CS23700 programming projects
|
#include <cs237-image.hpp>
Public Member Functions | |
Image2D (uint32_t wid, uint32_t ht, Channels chans, ChannelTy ty) | |
Image2D (std::string const &file, bool flip=true) | |
Image2D (std::ifstream &inS, bool flip=true) | |
size_t | width () const |
return the width of the image | |
size_t | height () const |
return the height of the image | |
bool | write (const char *file, bool flip=true) |
bool | write (std::ofstream &outS, bool flip=true) |
void | bitblt (Image2D const &src, uint32_t row, uint32_t col) |
Public Member Functions inherited from cs237::__detail::ImageBase | |
uint32_t | nDims () const |
the number of dimensions (1, 2, or 3) | |
Channels | channels () const |
return the format of the pixels. | |
ChannelTy | type () const |
returns the type of the channels | |
vk::Format | format () const |
return the vulkan format of the image data | |
void * | data () const |
the data pointer | |
size_t | nBytes () const |
the total number of bytes of image data | |
unsigned int | nChannels () const |
the number of channels (1, 2, 3, or 4) | |
size_t | nBytesPerPixel () const |
the number of bytes per pixel | |
void | addAlphaChannel () |
Protected Attributes | |
uint32_t | _wid |
the width of the image in pixels | |
uint32_t | _ht |
the height of the image in pixels | |
Protected Attributes inherited from cs237::__detail::ImageBase | |
uint32_t | _nDims |
the number of dimensions (1 or 2) | |
Channels | _chans |
the texture format | |
ChannelTy | _type |
the representation type of the data | |
bool | _sRGB |
should the image be interpreted as an sRGB encoded image? | |
size_t | _nBytes |
size in bytes of image data | |
void * | _data |
the raw image data | |
Additional Inherited Members | |
Protected Member Functions inherited from cs237::__detail::ImageBase | |
ImageBase () | |
ImageBase (uint32_t nd) | |
ImageBase (uint32_t nd, Channels chans, ChannelTy ty, size_t nPixels) | |
virtual | ~ImageBase () |
A 2D Image; by default, it is assumed to store color data, which means that RGB data will be interpreted as being sRGB encoded. Use the DataImage2D
class to represent unencoded image data.
create and allocate space for an uninitialized image
wid | the width of the image |
ht | the height of the image |
chans | the image format |
ty | the type of the elements |
cs237::Image2D::Image2D | ( | std::string const & | file, |
bool | flip = true |
||
) |
create and initialize an image from a PNG file.
file | the name of the PNG file |
flip | set to true if the image should be flipped vertically to match OpenGL texture coordinates (default true) |
cs237::Image2D::Image2D | ( | std::ifstream & | inS, |
bool | flip = true |
||
) |
create and initialize an image from a PNG-format input stream
inS | the input stream |
flip | set to true if the image should be flipped vertically to match OpenGL texture coordinates (default true) |
void cs237::Image2D::bitblt | ( | Image2D const & | src, |
uint32_t | row, | ||
uint32_t | col | ||
) |
copy the contents of another image into this image
src | the image to blt into this image |
row | the row of this image where the first row of src is copied |
col | the column of this image where the leftmost column of src is copied |
Note that this function requires that the two images have the same format and sample type.
|
inline |
return the height of the image
|
inline |
return the width of the image
bool cs237::Image2D::write | ( | const char * | file, |
bool | flip = true |
||
) |
write the texture to a file in PNG format
file | the name of the PNG file |
flip | set to true if the image should be flipped vertically to match standard image-file coordinates (default true) |
Note that the type of the image must be either GL_UNSIGNED_BYTE, or GL_UNSIGNED_SHORT to write it as a PNG file.
bool cs237::Image2D::write | ( | std::ofstream & | outS, |
bool | flip = true |
||
) |
write the texture to an output stream in PNG format
outS | the output stream to write the PNG image to |
flip | set to true if the image should be flipped vertically to match standard image-file coordinates (default true) |
Note that the type of the image must be either GL_UNSIGNED_BYTE, or GL_UNSIGNED_SHORT to write it to an output stream.
|
protected |
the height of the image in pixels
|
protected |
the width of the image in pixels