summaryrefslogtreecommitdiff
path: root/core/image.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/image.h')
-rw-r--r--core/image.h85
1 files changed, 37 insertions, 48 deletions
diff --git a/core/image.h b/core/image.h
index 1a257f28a0..310351e547 100644
--- a/core/image.h
+++ b/core/image.h
@@ -29,8 +29,8 @@
#ifndef IMAGE_H
#define IMAGE_H
-#include "dvector.h"
#include "color.h"
+#include "dvector.h"
#include "math_2d.h"
/**
* @author Juan Linietsky <reduzio@gmail.com>
@@ -42,16 +42,16 @@
class Image;
-typedef Error (*SavePNGFunc)(const String &p_path, Image& p_img);
+typedef Error (*SavePNGFunc)(const String &p_path, Image &p_img);
class Image {
enum {
- MAX_WIDTH=16384, // force a limit somehow
- MAX_HEIGHT=16384// force a limit somehow
+ MAX_WIDTH = 16384, // force a limit somehow
+ MAX_HEIGHT = 16384 // force a limit somehow
};
-public:
+public:
static SavePNGFunc save_png_func;
enum Format {
@@ -96,7 +96,7 @@ public:
FORMAT_MAX
};
- static const char* format_names[FORMAT_MAX];
+ static const char *format_names[FORMAT_MAX];
enum Interpolation {
INTERPOLATE_NEAREST,
@@ -107,8 +107,8 @@ public:
//some functions provided by something else
- static Image (*_png_mem_loader_func)(const uint8_t* p_png,int p_size);
- static Image (*_jpg_mem_loader_func)(const uint8_t* p_png,int p_size);
+ static Image (*_png_mem_loader_func)(const uint8_t *p_png, int p_size);
+ static Image (*_jpg_mem_loader_func)(const uint8_t *p_png, int p_size);
static void (*_image_compress_bc_func)(Image *);
static void (*_image_compress_pvrtc2_func)(Image *);
@@ -123,30 +123,26 @@ public:
Error _decompress_bc();
- static PoolVector<uint8_t> (*lossy_packer)(const Image& p_image,float p_quality);
- static Image (*lossy_unpacker)(const PoolVector<uint8_t>& p_buffer);
- static PoolVector<uint8_t> (*lossless_packer)(const Image& p_image);
- static Image (*lossless_unpacker)(const PoolVector<uint8_t>& p_buffer);
-private:
+ static PoolVector<uint8_t> (*lossy_packer)(const Image &p_image, float p_quality);
+ static Image (*lossy_unpacker)(const PoolVector<uint8_t> &p_buffer);
+ static PoolVector<uint8_t> (*lossless_packer)(const Image &p_image);
+ static Image (*lossless_unpacker)(const PoolVector<uint8_t> &p_buffer);
+private:
Format format;
PoolVector<uint8_t> data;
- int width,height;
+ int width, height;
bool mipmaps;
- _FORCE_INLINE_ void _get_mipmap_offset_and_size(int p_mipmap,int &r_offset, int &r_width, int &r_height) const; //get where the mipmap begins in data
+ _FORCE_INLINE_ void _get_mipmap_offset_and_size(int p_mipmap, int &r_offset, int &r_width, int &r_height) const; //get where the mipmap begins in data
- static int _get_dst_image_size(int p_width, int p_height, Format p_format,int &r_mipmaps,int p_mipmaps=-1);
+ static int _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1);
bool _can_modify(Format p_format) const;
-
- _FORCE_INLINE_ void _put_pixelb(int p_x,int p_y, uint32_t p_pixelsize,uint8_t *p_dst,const uint8_t *p_src);
- _FORCE_INLINE_ void _get_pixelb(int p_x,int p_y, uint32_t p_pixelsize,const uint8_t *p_src,uint8_t *p_dst);
+ _FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_dst, const uint8_t *p_src);
+ _FORCE_INLINE_ void _get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_src, uint8_t *p_dst);
public:
-
-
-
int get_width() const; ///< Get image width
int get_height() const; ///< Get image height
bool has_mipmaps() const;
@@ -155,7 +151,7 @@ public:
/**
* Convert the image to another format, conversion only to raw byte format
*/
- void convert( Format p_new_format );
+ void convert(Format p_new_format);
Image converted(int p_new_format) {
ERR_FAIL_INDEX_V(p_new_format, FORMAT_MAX, Image());
@@ -171,24 +167,23 @@ public:
Format get_format() const;
int get_mipmap_offset(int p_mipmap) const; //get where the mipmap begins in data
- void get_mipmap_offset_and_size(int p_mipmap,int &r_ofs, int &r_size) const; //get where the mipmap begins in data
- void get_mipmap_offset_size_and_dimensions(int p_mipmap,int &r_ofs, int &r_size,int &w, int& h) const; //get where the mipmap begins in data
+ void get_mipmap_offset_and_size(int p_mipmap, int &r_ofs, int &r_size) const; //get where the mipmap begins in data
+ void get_mipmap_offset_size_and_dimensions(int p_mipmap, int &r_ofs, int &r_size, int &w, int &h) const; //get where the mipmap begins in data
/**
* 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 );
- Image resized( int p_width, int p_height, int p_interpolation=INTERPOLATE_BILINEAR );
+ void resize_to_po2(bool p_square = false);
+ void resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
+ Image resized(int p_width, int p_height, int p_interpolation = INTERPOLATE_BILINEAR);
void shrink_x2();
void expand_x2_hq2x();
/**
* 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 crop(int p_width, int p_height);
void flip_x();
void flip_y();
@@ -200,15 +195,13 @@ public:
void clear_mipmaps();
-
-
/**
* Create a new image of a given size and format. Current image will be lost
*/
void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format);
- void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t>& p_data);
+ void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<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
*/
@@ -216,8 +209,8 @@ public:
PoolVector<uint8_t> get_data() const;
- Error load(const String& p_path);
- Error save_png(const String& p_path);
+ Error load(const String &p_path);
+ Error save_png(const String &p_path);
/**
* create an empty image
@@ -230,7 +223,7 @@ public:
/**
* import an image of a specific size and format from a pointer
*/
- Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector<uint8_t>& p_data);
+ Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data);
enum AlphaMode {
ALPHA_NONE,
@@ -241,16 +234,14 @@ public:
AlphaMode detect_alpha() const;
bool is_invisible() const;
-
static int get_format_pixel_size(Format p_format);
static int get_format_pixel_rshift(Format p_format);
- static void get_format_min_pixel_size(Format p_format,int &r_w, int &r_h);
+ static void get_format_min_pixel_size(Format p_format, int &r_w, int &r_h);
- static int get_image_data_size(int p_width, int p_height, Format p_format,int p_mipmaps=0);
+ static int get_image_data_size(int p_width, int p_height, Format p_format, int p_mipmaps = 0);
static int get_image_required_mipmaps(int p_width, int p_height, Format p_format);
-
- bool operator==(const Image& p_image) const;
+ bool operator==(const Image &p_image) const;
enum CompressMode {
COMPRESS_16BIT,
@@ -261,7 +252,7 @@ public:
COMPRESS_ETC2
};
- Error compress(CompressMode p_mode=COMPRESS_S3TC);
+ Error compress(CompressMode p_mode = COMPRESS_S3TC);
Image compressed(int p_mode); /* from the Image::CompressMode enum */
Error decompress();
Image decompressed() const;
@@ -272,19 +263,17 @@ public:
void srgb_to_linear();
void normalmap_to_xy();
- void blit_rect(const Image& p_src, const Rect2& p_src_rect,const Point2& p_dest);
+ void blit_rect(const Image &p_src, const Rect2 &p_src_rect, const Point2 &p_dest);
Rect2 get_used_rect() const;
- Image get_rect(const Rect2& p_area) const;
+ Image get_rect(const Rect2 &p_area) const;
static void set_compress_bc_func(void (*p_compress_func)(Image *));
static String get_format_name(Format p_format);
- Image(const uint8_t* p_mem_png_jpg, int p_len=-1);
+ Image(const uint8_t *p_mem_png_jpg, int p_len = -1);
Image(const char **p_xpm);
~Image();
-
};
-
#endif