2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* image.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2018-01-01 13:40:08 +00:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef IMAGE_H
|
|
|
|
#define IMAGE_H
|
|
|
|
|
|
|
|
#include "color.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "dvector.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "math_2d.h"
|
2017-05-17 10:36:47 +00:00
|
|
|
#include "resource.h"
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
/**
|
|
|
|
* @author Juan Linietsky <reduzio@gmail.com>
|
|
|
|
*
|
|
|
|
* Image storage class. This is used to store an image in user memory, as well as
|
|
|
|
* providing some basic methods for image manipulation.
|
|
|
|
* Images can be loaded from a file, or registered into the Render object as textures.
|
|
|
|
*/
|
|
|
|
|
2014-11-13 03:53:12 +00:00
|
|
|
class Image;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
typedef Error (*SavePNGFunc)(const String &p_path, const Ref<Image> &p_img);
|
2018-07-14 17:42:37 +00:00
|
|
|
typedef Ref<Image> (*ImageMemLoadFunc)(const uint8_t *p_png, int p_size);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
class Image : public Resource {
|
|
|
|
GDCLASS(Image, Resource);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-03-08 23:00:52 +00:00
|
|
|
enum {
|
2017-03-05 15:44:50 +00:00
|
|
|
MAX_WIDTH = 16384, // force a limit somehow
|
|
|
|
MAX_HEIGHT = 16384 // force a limit somehow
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2014-11-13 03:53:12 +00:00
|
|
|
static SavePNGFunc save_png_func;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
enum Format {
|
|
|
|
|
2016-10-03 19:33:42 +00:00
|
|
|
FORMAT_L8, //luminance
|
|
|
|
FORMAT_LA8, //luminance-alpha
|
|
|
|
FORMAT_R8,
|
|
|
|
FORMAT_RG8,
|
|
|
|
FORMAT_RGB8,
|
|
|
|
FORMAT_RGBA8,
|
|
|
|
FORMAT_RGBA4444,
|
|
|
|
FORMAT_RGBA5551,
|
|
|
|
FORMAT_RF, //float
|
|
|
|
FORMAT_RGF,
|
|
|
|
FORMAT_RGBF,
|
|
|
|
FORMAT_RGBAF,
|
|
|
|
FORMAT_RH, //half float
|
|
|
|
FORMAT_RGH,
|
|
|
|
FORMAT_RGBH,
|
|
|
|
FORMAT_RGBAH,
|
2017-05-27 00:49:49 +00:00
|
|
|
FORMAT_RGBE9995,
|
2016-10-03 19:33:42 +00:00
|
|
|
FORMAT_DXT1, //s3tc bc1
|
|
|
|
FORMAT_DXT3, //bc2
|
|
|
|
FORMAT_DXT5, //bc3
|
2017-05-27 00:49:49 +00:00
|
|
|
FORMAT_RGTC_R,
|
|
|
|
FORMAT_RGTC_RG,
|
|
|
|
FORMAT_BPTC_RGBA, //btpc bc7
|
|
|
|
FORMAT_BPTC_RGBF, //float bc6h
|
|
|
|
FORMAT_BPTC_RGBFU, //unsigned float bc6hu
|
2016-10-03 19:33:42 +00:00
|
|
|
FORMAT_PVRTC2, //pvrtc
|
|
|
|
FORMAT_PVRTC2A,
|
|
|
|
FORMAT_PVRTC4,
|
|
|
|
FORMAT_PVRTC4A,
|
|
|
|
FORMAT_ETC, //etc1
|
|
|
|
FORMAT_ETC2_R11, //etc2
|
|
|
|
FORMAT_ETC2_R11S, //signed, NOT srgb.
|
|
|
|
FORMAT_ETC2_RG11,
|
|
|
|
FORMAT_ETC2_RG11S,
|
|
|
|
FORMAT_ETC2_RGB8,
|
|
|
|
FORMAT_ETC2_RGBA8,
|
|
|
|
FORMAT_ETC2_RGB8A1,
|
2014-02-10 01:10:30 +00:00
|
|
|
FORMAT_MAX
|
|
|
|
};
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
static const char *format_names[FORMAT_MAX];
|
2014-02-10 01:10:30 +00:00
|
|
|
enum Interpolation {
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
INTERPOLATE_NEAREST,
|
|
|
|
INTERPOLATE_BILINEAR,
|
2015-10-01 19:25:36 +00:00
|
|
|
INTERPOLATE_CUBIC,
|
2018-06-01 19:53:35 +00:00
|
|
|
INTERPOLATE_TRILINEAR,
|
|
|
|
/* INTERPOLATE_TRICUBIC, */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* INTERPOLATE GAUSS */
|
|
|
|
};
|
|
|
|
|
2017-06-17 00:47:28 +00:00
|
|
|
enum CompressSource {
|
|
|
|
COMPRESS_SOURCE_GENERIC,
|
|
|
|
COMPRESS_SOURCE_SRGB,
|
2018-08-06 17:56:06 +00:00
|
|
|
COMPRESS_SOURCE_NORMAL,
|
|
|
|
COMPRESS_SOURCE_LAYERED,
|
2017-06-17 00:47:28 +00:00
|
|
|
};
|
|
|
|
|
2016-10-03 19:33:42 +00:00
|
|
|
//some functions provided by something else
|
|
|
|
|
2018-07-14 17:42:37 +00:00
|
|
|
static ImageMemLoadFunc _png_mem_loader_func;
|
|
|
|
static ImageMemLoadFunc _jpg_mem_loader_func;
|
|
|
|
static ImageMemLoadFunc _webp_mem_loader_func;
|
2016-10-03 19:33:42 +00:00
|
|
|
|
2017-06-17 00:47:28 +00:00
|
|
|
static void (*_image_compress_bc_func)(Image *, CompressSource p_source);
|
2014-02-10 01:10:30 +00:00
|
|
|
static void (*_image_compress_pvrtc2_func)(Image *);
|
|
|
|
static void (*_image_compress_pvrtc4_func)(Image *);
|
2017-04-26 15:49:08 +00:00
|
|
|
static void (*_image_compress_etc1_func)(Image *, float);
|
2017-06-17 00:47:28 +00:00
|
|
|
static void (*_image_compress_etc2_func)(Image *, float, CompressSource p_source);
|
2016-10-03 19:33:42 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
static void (*_image_decompress_pvrtc)(Image *);
|
|
|
|
static void (*_image_decompress_bc)(Image *);
|
2017-04-26 15:49:08 +00:00
|
|
|
static void (*_image_decompress_etc1)(Image *);
|
2016-10-03 19:33:42 +00:00
|
|
|
static void (*_image_decompress_etc2)(Image *);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
static PoolVector<uint8_t> (*lossy_packer)(const Ref<Image> &p_image, float p_quality);
|
|
|
|
static Ref<Image> (*lossy_unpacker)(const PoolVector<uint8_t> &p_buffer);
|
|
|
|
static PoolVector<uint8_t> (*lossless_packer)(const Ref<Image> &p_image);
|
|
|
|
static Ref<Image> (*lossless_unpacker)(const PoolVector<uint8_t> &p_buffer);
|
|
|
|
|
2017-05-27 00:49:49 +00:00
|
|
|
PoolVector<uint8_t>::Write write_lock;
|
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
private:
|
2017-05-17 10:36:47 +00:00
|
|
|
void _create_empty(int p_width, int p_height, bool p_use_mipmaps, Format p_format) {
|
|
|
|
create(p_width, p_height, p_use_mipmaps, p_format);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _create_from_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data) {
|
|
|
|
create(p_width, p_height, p_use_mipmaps, p_format, p_data);
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Format format;
|
2017-01-07 21:25:37 +00:00
|
|
|
PoolVector<uint8_t> data;
|
2017-03-05 15:44:50 +00:00
|
|
|
int width, height;
|
2016-10-03 19:33:42 +00:00
|
|
|
bool mipmaps;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
void _copy_internals_from(const Image &p_image) {
|
|
|
|
format = p_image.format;
|
|
|
|
width = p_image.width;
|
|
|
|
height = p_image.height;
|
|
|
|
mipmaps = p_image.mipmaps;
|
|
|
|
data = p_image.data;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
_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
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
static int _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1);
|
2014-02-10 01:10:30 +00:00
|
|
|
bool _can_modify(Format p_format) const;
|
|
|
|
|
2017-06-09 03:23:50 +00:00
|
|
|
_FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel);
|
|
|
|
_FORCE_INLINE_ void _get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_data, uint8_t *p_pixel);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
void _set_data(const Dictionary &p_data);
|
|
|
|
Dictionary _get_data() const;
|
|
|
|
|
2018-07-14 17:42:37 +00:00
|
|
|
Error _load_from_buffer(const PoolVector<uint8_t> &p_array, ImageMemLoadFunc p_loader);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
public:
|
|
|
|
int get_width() const; ///< Get image width
|
|
|
|
int get_height() const; ///< Get image height
|
2017-08-26 11:45:03 +00:00
|
|
|
Vector2 get_size() const;
|
2016-10-03 19:33:42 +00:00
|
|
|
bool has_mipmaps() const;
|
|
|
|
int get_mipmap_count() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
/**
|
2016-10-03 19:33:42 +00:00
|
|
|
* Convert the image to another format, conversion only to raw byte format
|
2014-02-10 01:10:30 +00:00
|
|
|
*/
|
2017-03-05 15:44:50 +00:00
|
|
|
void convert(Format p_new_format);
|
2014-10-03 03:10:51 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
/**
|
|
|
|
* Get the current image format.
|
|
|
|
*/
|
|
|
|
Format get_format() const;
|
|
|
|
|
|
|
|
int get_mipmap_offset(int p_mipmap) const; //get where the mipmap begins in data
|
2017-03-05 15:44:50 +00:00
|
|
|
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
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
/**
|
2017-03-24 20:45:31 +00:00
|
|
|
* Resize the image, using the preferred interpolation method.
|
2014-02-10 01:10:30 +00:00
|
|
|
* Indexed-Color images always use INTERPOLATE_NEAREST.
|
2016-03-08 23:00:52 +00:00
|
|
|
*/
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void resize_to_po2(bool p_square = false);
|
|
|
|
void resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
|
2016-05-04 15:36:51 +00:00
|
|
|
void shrink_x2();
|
2016-05-29 14:37:26 +00:00
|
|
|
void expand_x2_hq2x();
|
2014-02-10 01:10:30 +00:00
|
|
|
/**
|
|
|
|
* Crop the image to a specific size, if larger, then the image is filled by black
|
|
|
|
*/
|
2017-11-18 03:42:14 +00:00
|
|
|
void crop_from_point(int p_x, int p_y, int p_width, int p_height);
|
2017-03-05 15:44:50 +00:00
|
|
|
void crop(int p_width, int p_height);
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void flip_x();
|
|
|
|
void flip_y();
|
2016-10-03 19:33:42 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
/**
|
2016-03-08 23:00:52 +00:00
|
|
|
* Generate a mipmap to an image (creates an image 1/4 the size, with averaging of 4->1)
|
2014-02-10 01:10:30 +00:00
|
|
|
*/
|
2018-04-30 00:51:37 +00:00
|
|
|
Error generate_mipmaps(bool p_renormalize = false);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void clear_mipmaps();
|
2018-07-03 13:55:50 +00:00
|
|
|
void normalize(); //for normal maps
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2017-03-05 15:44:50 +00:00
|
|
|
void create(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void create(const char **p_xpm);
|
2014-02-10 01:10:30 +00:00
|
|
|
/**
|
|
|
|
* returns true when the image is empty (0,0) in size
|
|
|
|
*/
|
|
|
|
bool empty() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2017-01-07 21:25:37 +00:00
|
|
|
PoolVector<uint8_t> get_data() const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Error load(const String &p_path);
|
2017-04-30 01:14:14 +00:00
|
|
|
Error save_png(const String &p_path) const;
|
2016-03-08 23:00:52 +00:00
|
|
|
|
|
|
|
/**
|
2014-02-10 01:10:30 +00:00
|
|
|
* create an empty image
|
|
|
|
*/
|
|
|
|
Image();
|
2016-03-08 23:00:52 +00:00
|
|
|
/**
|
2014-02-10 01:10:30 +00:00
|
|
|
* create an empty image of a specific size and format
|
|
|
|
*/
|
|
|
|
Image(int p_width, int p_height, bool p_use_mipmaps, Format p_format);
|
2016-03-08 23:00:52 +00:00
|
|
|
/**
|
2014-02-10 01:10:30 +00:00
|
|
|
* import an image of a specific size and format from a pointer
|
|
|
|
*/
|
2017-03-05 15:44:50 +00:00
|
|
|
Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const PoolVector<uint8_t> &p_data);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
enum AlphaMode {
|
|
|
|
ALPHA_NONE,
|
|
|
|
ALPHA_BIT,
|
|
|
|
ALPHA_BLEND
|
|
|
|
};
|
|
|
|
|
|
|
|
AlphaMode detect_alpha() const;
|
2015-06-01 22:42:34 +00:00
|
|
|
bool is_invisible() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
static int get_format_pixel_size(Format p_format);
|
|
|
|
static int get_format_pixel_rshift(Format p_format);
|
2017-05-27 00:49:49 +00:00
|
|
|
static int get_format_block_size(Format p_format);
|
2017-03-05 15:44:50 +00:00
|
|
|
static void get_format_min_pixel_size(Format p_format, int &r_w, int &r_h);
|
2016-10-03 19:33:42 +00:00
|
|
|
|
2018-08-06 17:56:06 +00:00
|
|
|
static int get_image_data_size(int p_width, int p_height, Format p_format, bool p_mipmaps = false);
|
2014-02-10 01:10:30 +00:00
|
|
|
static int get_image_required_mipmaps(int p_width, int p_height, Format p_format);
|
|
|
|
|
|
|
|
enum CompressMode {
|
2016-10-03 19:33:42 +00:00
|
|
|
COMPRESS_S3TC,
|
2014-02-10 01:10:30 +00:00
|
|
|
COMPRESS_PVRTC2,
|
|
|
|
COMPRESS_PVRTC4,
|
2016-10-03 19:33:42 +00:00
|
|
|
COMPRESS_ETC,
|
2017-05-27 00:49:49 +00:00
|
|
|
COMPRESS_ETC2,
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-06-17 00:47:28 +00:00
|
|
|
Error compress(CompressMode p_mode = COMPRESS_S3TC, CompressSource p_source = COMPRESS_SOURCE_GENERIC, float p_lossy_quality = 0.7);
|
2014-06-11 13:41:03 +00:00
|
|
|
Error decompress();
|
2015-05-31 04:59:42 +00:00
|
|
|
bool is_compressed() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void fix_alpha_edges();
|
2014-05-24 04:35:47 +00:00
|
|
|
void premultiply_alpha();
|
2014-06-16 13:22:26 +00:00
|
|
|
void srgb_to_linear();
|
2014-10-03 11:58:41 +00:00
|
|
|
void normalmap_to_xy();
|
2018-05-30 19:14:07 +00:00
|
|
|
Ref<Image> rgbe_to_srgb();
|
2018-02-24 00:59:02 +00:00
|
|
|
void bumpmap_to_normalmap(float bump_scale = 1.0);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
void blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest);
|
2017-06-24 15:53:54 +00:00
|
|
|
void blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest);
|
2017-06-18 16:38:43 +00:00
|
|
|
void blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest);
|
|
|
|
void blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest);
|
|
|
|
void fill(const Color &c);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
Rect2 get_used_rect() const;
|
2017-05-17 10:36:47 +00:00
|
|
|
Ref<Image> get_rect(const Rect2 &p_area) const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-17 00:47:28 +00:00
|
|
|
static void set_compress_bc_func(void (*p_compress_func)(Image *, CompressSource));
|
2015-10-21 12:50:44 +00:00
|
|
|
static String get_format_name(Format p_format);
|
|
|
|
|
2017-12-20 20:16:21 +00:00
|
|
|
Error load_png_from_buffer(const PoolVector<uint8_t> &p_array);
|
|
|
|
Error load_jpg_from_buffer(const PoolVector<uint8_t> &p_array);
|
2018-07-14 17:42:37 +00:00
|
|
|
Error load_webp_from_buffer(const PoolVector<uint8_t> &p_array);
|
2017-12-20 20:16:21 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Image(const uint8_t *p_mem_png_jpg, int p_len = -1);
|
2014-02-10 01:10:30 +00:00
|
|
|
Image(const char **p_xpm);
|
2017-05-17 10:36:47 +00:00
|
|
|
|
|
|
|
virtual Ref<Resource> duplicate(bool p_subresources = false) const;
|
|
|
|
|
2017-05-27 00:49:49 +00:00
|
|
|
void lock();
|
|
|
|
void unlock();
|
|
|
|
|
|
|
|
//this is used for compression
|
|
|
|
enum DetectChannels {
|
|
|
|
DETECTED_L,
|
|
|
|
DETECTED_LA,
|
|
|
|
DETECTED_R,
|
|
|
|
DETECTED_RG,
|
|
|
|
DETECTED_RGB,
|
|
|
|
DETECTED_RGBA,
|
|
|
|
};
|
|
|
|
|
|
|
|
DetectChannels get_detected_channels();
|
2018-08-06 17:56:06 +00:00
|
|
|
void optimize_channels();
|
2017-05-27 00:49:49 +00:00
|
|
|
|
2018-04-29 13:17:06 +00:00
|
|
|
Color get_pixelv(const Point2 &p_src) const;
|
2017-06-17 00:28:58 +00:00
|
|
|
Color get_pixel(int p_x, int p_y) const;
|
2018-04-29 13:17:06 +00:00
|
|
|
void set_pixelv(const Point2 &p_dest, const Color &p_color);
|
2017-07-07 17:05:45 +00:00
|
|
|
void set_pixel(int p_x, int p_y, const Color &p_color);
|
2017-05-27 00:49:49 +00:00
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
void copy_internals_from(const Ref<Image> &p_image) {
|
|
|
|
ERR_FAIL_COND(p_image.is_null());
|
|
|
|
format = p_image->format;
|
|
|
|
width = p_image->width;
|
|
|
|
height = p_image->height;
|
|
|
|
mipmaps = p_image->mipmaps;
|
|
|
|
data = p_image->data;
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
~Image();
|
|
|
|
};
|
|
|
|
|
2017-05-17 10:36:47 +00:00
|
|
|
VARIANT_ENUM_CAST(Image::Format)
|
|
|
|
VARIANT_ENUM_CAST(Image::Interpolation)
|
|
|
|
VARIANT_ENUM_CAST(Image::CompressMode)
|
2017-06-17 00:47:28 +00:00
|
|
|
VARIANT_ENUM_CAST(Image::CompressSource)
|
2017-05-17 10:36:47 +00:00
|
|
|
VARIANT_ENUM_CAST(Image::AlphaMode)
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#endif
|