diff options
Diffstat (limited to 'core/image.h')
| -rw-r--r-- | core/image.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/core/image.h b/core/image.h index 7a6ee1e4b0..a155823af7 100644 --- a/core/image.h +++ b/core/image.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -40,7 +40,9 @@ * Images can be loaded from a file, or registered into the Render object as textures. */ +class Image; +typedef Error (*SavePNGFunc)(const String &p_path, Image& p_img); class Image { @@ -50,6 +52,8 @@ class Image { }; public: + static SavePNGFunc save_png_func; + enum Format { FORMAT_GRAYSCALE, ///< one byte per pixel, 0-255 FORMAT_INTENSITY, ///< one byte per pixel, 0-255 @@ -83,14 +87,16 @@ public: FORMAT_MAX }; + static const char* format_names[FORMAT_MAX]; enum Interpolation { INTERPOLATE_NEAREST, INTERPOLATE_BILINEAR, + INTERPOLATE_CUBIC, /* INTERPOLATE GAUSS */ }; - static Image (*_png_mem_loader_func)(const uint8_t* p_png); + static Image (*_png_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 *); static void (*_image_compress_pvrtc4_func)(Image *); @@ -216,6 +222,14 @@ public: * Convert the image to another format, as close as it can be done. */ void convert( Format p_new_format ); + + Image converted(int p_new_format) { + ERR_FAIL_INDEX_V(p_new_format, FORMAT_MAX, Image()); + + Image ret = *this; + ret.convert((Format)p_new_format); + return ret; + }; /** * Get the current image format. @@ -224,6 +238,7 @@ public: 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 /** * Resize the image, using the prefered interpolation method. @@ -270,6 +285,7 @@ public: DVector<uint8_t> get_data() const; Error load(const String& p_path); + Error save_png(const String& p_path); /** * create an empty image @@ -291,6 +307,7 @@ public: }; AlphaMode detect_alpha() const; + bool is_invisible() const; void put_indexed_pixel(int p_x, int p_y, uint8_t p_idx,int p_mipmap=0); uint8_t get_indexed_pixel(int p_x, int p_y,int p_mipmap=0) const; @@ -321,10 +338,12 @@ public: Image compressed(int p_mode); /* from the Image::CompressMode enum */ Error decompress(); Image decompressed() const; + bool is_compressed() const; void fix_alpha_edges(); void premultiply_alpha(); 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 brush_transfer(const Image& p_src, const Image& p_brush, const Point2& p_dest); @@ -334,7 +353,9 @@ public: Image get_rect(const Rect2& p_area) const; static void set_compress_bc_func(void (*p_compress_func)(Image *)); - Image(const uint8_t* p_mem_png); + static String get_format_name(Format p_format); + + Image(const uint8_t* p_mem_png, int p_len=-1); Image(const char **p_xpm); ~Image(); |