45 typedef Error (*SavePNGFunc)(
const String &p_path,
Image& p_img);
55 static SavePNGFunc save_png_func;
78 FORMAT_ATC_ALPHA_EXPLICIT,
79 FORMAT_ATC_ALPHA_INTERPOLATED,
90 static const char* format_names[FORMAT_MAX];
99 static Image (*_png_mem_loader_func)(
const uint8_t* p_png,
int p_size);
100 static void (*_image_compress_bc_func)(
Image *);
101 static void (*_image_compress_pvrtc2_func)(
Image *);
102 static void (*_image_compress_pvrtc4_func)(
Image *);
103 static void (*_image_compress_etc_func)(
Image *);
104 static void (*_image_decompress_pvrtc)(
Image *);
105 static void (*_image_decompress_bc)(
Image *);
106 static void (*_image_decompress_etc)(
Image *);
108 Error _decompress_bc();
125 bool operator==(
const BColor& p_color)
const {
for(
int i=0;i<4;i++) {
if (col[i]!=p_color.col[i])
return false; }
return true; }
126 _FORCE_INLINE_ uint8_t gray()
const {
return (uint16_t(col[0])+uint16_t(col[1])+uint16_t(col[2]))/3; }
127 _FORCE_INLINE_ BColor() {}
128 BColor(uint8_t p_r,uint8_t p_g,uint8_t p_b,uint8_t p_a=255) { col[0]=p_r; col[1]=p_g; col[2]=p_b; col[3]=p_a; }
139 bool operator()(
const BColorPos& ca,
const BColorPos& cb)
const {
return ca.color.r < cb.color.r; }
144 bool operator()(
const BColorPos& ca,
const BColorPos& cb)
const {
return ca.color.g < cb.color.g; }
149 bool operator()(
const BColorPos& ca,
const BColorPos& cb)
const {
return ca.color.b < cb.color.b; }
154 bool operator()(
const BColorPos& ca,
const BColorPos& cb)
const {
return ca.color.a < cb.color.a; }
168 SPTree() { leaf=
true; left=-1; right=-1;}
173 BColorPos min_color,max_color;
177 int get_longest_axis_index()
const;
178 int get_longest_axis_length()
const;
179 bool operator<(
const MCBlock& p_block)
const;
182 MCBlock(BColorPos *p_colors,
int p_color_count);
187 int width,height,mipmaps;
191 _FORCE_INLINE_ BColor _get_pixel(
int p_x,
int p_y,
const unsigned char *p_data,
int p_data_size)
const;
192 _FORCE_INLINE_ BColor _get_pixelw(
int p_x,
int p_y,
int p_width,
const unsigned char *p_data,
int p_data_size)
const;
193 _FORCE_INLINE_
void _put_pixelw(
int p_x,
int p_y,
int p_width,
const BColor& p_color,
unsigned char *p_data);
194 _FORCE_INLINE_
void _put_pixel(
int p_x,
int p_y,
const BColor& p_color,
unsigned char *p_data);
195 _FORCE_INLINE_
void _get_mipmap_offset_and_size(
int p_mipmap,
int &r_offset,
int &r_width,
int &r_height)
const;
196 _FORCE_INLINE_
static void _get_format_min_data_size(
Format p_format,
int &r_w,
int &r_h);
198 static int _get_dst_image_size(
int p_width,
int p_height,
Format p_format,
int &r_mipmaps,
int p_mipmaps=-1);
199 bool _can_modify(
Format p_format)
const;
209 int get_mipmaps()
const;
219 void put_pixel(
int p_x,
int p_y,
const Color& p_color,
int p_mipmap=0);
226 Image converted(
int p_new_format) {
227 ERR_FAIL_INDEX_V(p_new_format, FORMAT_MAX,
Image());
239 int get_mipmap_offset(
int p_mipmap)
const;
240 void get_mipmap_offset_and_size(
int p_mipmap,
int &r_ofs,
int &r_size)
const;
241 void get_mipmap_offset_size_and_dimensions(
int p_mipmap,
int &r_ofs,
int &r_size,
int &w,
int& h)
const;
249 void resize(
int p_width,
int p_height, Interpolation p_interpolation=INTERPOLATE_BILINEAR );
250 Image resized(
int p_width,
int p_height,
int p_interpolation=INTERPOLATE_BILINEAR );
255 void crop(
int p_width,
int p_height );
265 void clear_mipmaps();
277 void create(
int p_width,
int p_height,
bool p_use_mipmaps,
Format p_format);
280 void create(
const char ** p_xpm );
288 Error load(
const String& p_path);
289 Error save_png(
const String& p_path);
298 Image(
int p_width,
int p_height,
bool p_use_mipmaps,
Format p_format);
310 AlphaMode detect_alpha()
const;
311 bool is_invisible()
const;
313 void put_indexed_pixel(
int p_x,
int p_y, uint8_t p_idx,
int p_mipmap=0);
314 uint8_t get_indexed_pixel(
int p_x,
int p_y,
int p_mipmap=0)
const;
318 static int get_format_pixel_size(
Format p_format);
319 static int get_format_pixel_rshift(
Format p_format);
320 static int get_format_pallete_size(
Format p_format);
321 static int get_image_data_size(
int p_width,
int p_height,
Format p_format,
int p_mipmaps=0);
322 static int get_image_required_mipmaps(
int p_width,
int p_height,
Format p_format);
327 bool operator==(
const Image& p_image)
const;
338 Error compress(CompressMode p_mode=COMPRESS_BC);
339 Image compressed(
int p_mode);
341 Image decompressed()
const;
342 bool is_compressed()
const;
344 void fix_alpha_edges();
345 void premultiply_alpha();
346 void srgb_to_linear();
347 void normalmap_to_xy();
349 void blit_rect(
const Image& p_src,
const Rect2& p_src_rect,
const Point2& p_dest);
350 void brush_transfer(
const Image& p_src,
const Image& p_brush,
const Point2& p_dest);
353 Rect2 get_used_rect()
const;
356 static void set_compress_bc_func(
void (*p_compress_func)(
Image *));
359 Image(
const uint8_t* p_mem_png,
int p_len=-1);
360 Image(
const char **p_xpm);
void put_pixel(int p_x, int p_y, const Color &p_color, int p_mipmap=0)
Definition: image.cpp:176
void make_normalmap(float p_height_scale=1.0)
Definition: image.cpp:1095
two bytes per pixel, 0-255. alpha 0-255
Definition: image.h:60
int get_height() const
Get image height.
Definition: image.cpp:335
Format
Definition: image.h:57
Definition: math_2d.h:204
Image()
Definition: image.cpp:2478
Color get_pixel(int p_x, int p_y, int p_mipmap=0) const
Definition: image.cpp:346
index byte 0-256, and after image end, 256*3 bytes of palette
Definition: image.h:63
one byte per pixel, 0-255
Definition: image.h:59
Format get_format() const
Definition: image.cpp:425
bool empty() const
Definition: image.cpp:1128
index byte 0-256, and after image end, 256*4 bytes of palette (alpha)
Definition: image.h:64
one byte per pixel, 0-255
Definition: image.h:58
void convert(Format p_new_format)
Definition: image.cpp:363
one byte R, one byte G, one byte B
Definition: image.h:61
int get_width() const
Get image width.
Definition: image.cpp:331
Error generate_mipmaps(int p_amount=-1, bool p_keep_existing=false)
Definition: image.cpp:964
one byte R, one byte G, one byte B, one byte A
Definition: image.h:62
void crop(int p_width, int p_height)
Definition: image.cpp:707
void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format)
Definition: image.cpp:1138
void resize_to_po2(bool p_square=false)
Definition: image.cpp:607