diff options
Diffstat (limited to 'core/image.h')
-rw-r--r-- | core/image.h | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/core/image.h b/core/image.h index aea5dc6438..8f8fff755e 100644 --- a/core/image.h +++ b/core/image.h @@ -46,7 +46,7 @@ typedef Error (*SavePNGFunc)(const String &p_path, Image& p_img); class Image { - enum { + enum { MAX_WIDTH=16384, // force a limit somehow MAX_HEIGHT=16384// force a limit somehow }; @@ -55,12 +55,12 @@ public: static SavePNGFunc save_png_func; enum Format { - FORMAT_GRAYSCALE, ///< one byte per pixel, 0-255 - FORMAT_INTENSITY, ///< one byte per pixel, 0-255 - FORMAT_GRAYSCALE_ALPHA, ///< two bytes per pixel, 0-255. alpha 0-255 - FORMAT_RGB, ///< one byte R, one byte G, one byte B - FORMAT_RGBA, ///< one byte R, one byte G, one byte B, one byte A - FORMAT_INDEXED, ///< index byte 0-256, and after image end, 256*3 bytes of palette + FORMAT_GRAYSCALE, ///< one byte per pixel, 0-255 + FORMAT_INTENSITY, ///< one byte per pixel, 0-255 + FORMAT_GRAYSCALE_ALPHA, ///< two bytes per pixel, 0-255. alpha 0-255 + FORMAT_RGB, ///< one byte R, one byte G, one byte B + FORMAT_RGBA, ///< one byte R, one byte G, one byte B, one byte A + FORMAT_INDEXED, ///< index byte 0-256, and after image end, 256*3 bytes of palette FORMAT_INDEXED_ALPHA, ///< index byte 0-256, and after image end, 256*4 bytes of palette (alpha) FORMAT_YUV_422, FORMAT_YUV_444, @@ -89,7 +89,7 @@ public: static const char* format_names[FORMAT_MAX]; enum Interpolation { - + INTERPOLATE_NEAREST, INTERPOLATE_BILINEAR, INTERPOLATE_CUBIC, @@ -186,7 +186,7 @@ private: DVector<uint8_t> data; int width,height,mipmaps; - + _FORCE_INLINE_ BColor _get_pixel(int p_x,int p_y,const unsigned char *p_data,int p_data_size) const; _FORCE_INLINE_ BColor _get_pixelw(int p_x,int p_y,int p_width,const unsigned char *p_data,int p_data_size) const; @@ -207,7 +207,7 @@ public: int get_width() const; ///< Get image width int get_height() const; ///< Get image height int get_mipmaps() const; - + /** * Get a pixel from the image. for grayscale or indexed formats, use Color::gray to obtain the actual * value. @@ -217,7 +217,7 @@ public: * Set a pixel into the image. for grayscale or indexed formats, a suitable Color constructor. */ void put_pixel(int p_x,int p_y, const Color& p_color,int p_mipmap=0); /* alpha and index are averaged */ - + /** * Convert the image to another format, as close as it can be done. */ @@ -230,7 +230,7 @@ public: ret.convert((Format)p_new_format); return ret; }; - + /** * Get the current image format. */ @@ -243,7 +243,7 @@ public: /** * Resize the image, using the prefered interpolation method. * Indexed-Color images always use INTERPOLATE_NEAREST. - */ + */ void resize_to_po2(bool p_square=false); void resize( int p_width, int p_height, Interpolation p_interpolation=INTERPOLATE_BILINEAR ); @@ -252,22 +252,22 @@ public: * Crop the image to a specific size, if larger, then the image is filled by black */ void crop( int p_width, int p_height ); - - + + void flip_x(); void flip_y(); /** - * Generate a mipmap to an image (creates an image 1/4 the size, with averaging of 4->1) + * Generate a mipmap to an image (creates an image 1/4 the size, with averaging of 4->1) */ Error generate_mipmaps(int p_amount=-1,bool p_keep_existing=false); void clear_mipmaps(); - + /** * Generate a normal map from a grayscale image */ - + void make_normalmap(float p_height_scale=1.0); /** @@ -276,26 +276,26 @@ public: void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format); void create(int p_width, int p_height, int p_mipmaps, Format p_format, const DVector<uint8_t>& p_data); - void create( const char ** p_xpm ); + void create( const char ** p_xpm ); /** * returns true when the image is empty (0,0) in size */ bool empty() const; - + DVector<uint8_t> get_data() const; - + Error load(const String& p_path); Error save_png(const String& p_path); - - /** + + /** * create an empty image */ Image(); - /** + /** * create an empty image of a specific size and format */ Image(int p_width, int p_height, bool p_use_mipmaps, Format p_format); - /** + /** * import an image of a specific size and format from a pointer */ Image(int p_width, int p_height, int p_mipmaps, Format p_format, const DVector<uint8_t>& p_data); @@ -313,7 +313,7 @@ public: uint8_t get_indexed_pixel(int p_x, int p_y,int p_mipmap=0) const; void set_pallete(const DVector<uint8_t>& p_data); - + static int get_format_pixel_size(Format p_format); static int get_format_pixel_rshift(Format p_format); static int get_format_pallete_size(Format p_format); |