#include <Image.h>
Public Types | |
| enum | { GRAY_MASK = 1 } |
| Converts the image to vector. More... | |
Public Member Functions | |
| Image (unsigned xs, unsigned ys) | |
| new image of undefined content in default RGBA pixel format | |
| void | resize (unsigned xs, unsigned ys) |
| ~Image () | |
| void | toFile (const std::string &fileName) |
| Save image to file (BMP). | |
| Image * | subImage (unsigned width, unsigned height, unsigned xOffset=0, unsigned yOffset=0) const |
| Create a sub-image of the original. | |
| void | setSubImage (const Image &src, unsigned xo=0, unsigned yo=0) |
| Copy contents of image from the src image to given offset. | |
| Color | getAverageColor () const throw (Exception) |
| Image * | toRGBA () const |
| Image pixel format will be converted to RGBA (one pixel = one byte) Unless you know the input image format, you should convert image with this function before making training examples from a loaded image. | |
| Image * | clone () const |
| copy this image (the result is independent) | |
| Image * | upsideDown () const |
| flip image | |
| Image * | toGray () const |
| Image will be converted to 32-RGBA (one pixel = four bytes). | |
| unsigned | getWidth () const |
| unsigned | getHeight () const |
| unsigned | getBPP () const |
| Vector | toVector (uint8_t bytes_mask) const |
| void | display (unsigned xo=0, unsigned yo=0) const |
| display to the video window (offsets are relative to win coords) if !gl, the video surface is flipped automatically (so far) - under GL you have to do it yourself (in GL mode, the offset is passed directly to glRasterPos --> it's up to caller to give it sense | |
| void | clear () |
| void | rect (const Color &c, uint x1, uint y1, uint x2, uint y2) |
| void | putPixel (const Color &c, uint x, uint y) |
| draw a pixel TODO: avoid frequent locking??? | |
| Color | getPixel (uint x, uint y) const |
| get a pixel | |
| real | getPixelGray (uint x, uint y) const |
| return the pixel as [0,1] gray | |
Static Public Member Functions | |
| Image * | fromFile (const std::string &fileName) |
| Image * | fromVector (const Vector &v, unsigned width, bool gray) |
| Creates an image from a vector of [0,1] reals. | |
Protected Member Functions | |
| Image (SDL_Surface *i) | |
| Create image wrapping the given surface. | |
| int | glFormat () const |
| void | setGlPixelStore (bool unpack) const |
| SDL_Surface * | createSameSurface (uint width, uint height) const |
| create void surface with the same flags as this | |
| SDL_Surface * | createSameSurface () const |
| void | glDraw () const |
| direct GL draw (assuming rasterPosition is set) | |
| void | colorless () |
| Average the color components. | |
| uint32_t | color2SDL (const Color &c) const |
| uint32_t | getPixelRaw (uint x, uint y) const |
| Color | sdl2color (uint32_t p) const |
Protected Attributes | |
| SDL_Surface * | surface |
Unless you force it by to* functions, you can assume nothing about pixel format of the image! Typical use would therefore be:
Image *raw = Image::fromFile(...); if(!raw) ... Image *rgb_img = raw->toRGBA(); delete(raw); if(!rgb_img) ... rgb_img-toVector(...) delete(rgb_img);NOTE: some const functions may in theory change state of the Image because they lock the surface Image uses window coordinates where 0,0 is top-left
|
|
Converts the image to vector. Each choosen byte is mapped into [0,1] real (0=black)
|
|
||||||||||||
|
new image of undefined content in default RGBA pixel format
|
|
|
|
|
|
Create image wrapping the given surface. The created image owns the surface and will free in destructor. |
|
|
|
|
|
copy this image (the result is independent)
|
|
|
|
|
|
Average the color components. The surface must have 4-bytes-per-pixel. The result is a grayscale-looking surface (but it is still RGBA!) |
|
|
|
|
||||||||||||
|
create void surface with the same flags as this
|
|
||||||||||||
|
display to the video window (offsets are relative to win coords) if !gl, the video surface is flipped automatically (so far) - under GL you have to do it yourself (in GL mode, the offset is passed directly to glRasterPos --> it's up to caller to give it sense
|
|
|
|
|
||||||||||||||||
|
Creates an image from a vector of [0,1] reals. The real images are mapped into color component bytes (R,G,B or Y,Y,Y (graY))
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
get a pixel
|
|
||||||||||||
|
return the pixel as [0,1] gray
|
|
||||||||||||
|
|
|
|
|
|
|
direct GL draw (assuming rasterPosition is set)
|
|
|
|
|
||||||||||||||||
|
draw a pixel TODO: avoid frequent locking???
|
|
||||||||||||||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
||||||||||||||||
|
Copy contents of image from the src image to given offset. The source image can be smaller, but not larger |
|
||||||||||||||||||||
|
Create a sub-image of the original. Resulting image has the same pixel format.
|
|
|
Save image to file (BMP).
|
|
|
Image will be converted to 32-RGBA (one pixel = four bytes). But all three RGB components are equal, so the image is grayscale-only. TODO: could we use one-byte SDL surface? We'd probably need to use palleted surface so the displayed image would be correct. |
|
|
Image pixel format will be converted to RGBA (one pixel = one byte) Unless you know the input image format, you should convert image with this function before making training examples from a loaded image.
|
|
|
|
|
|
flip image
|
|
|
|
1.3.5