|
@@ -85,6 +85,8 @@ const char *Image::format_names[Image::FORMAT_MAX] = {
|
|
SavePNGFunc Image::save_png_func = NULL;
|
|
SavePNGFunc Image::save_png_func = NULL;
|
|
SaveEXRFunc Image::save_exr_func = NULL;
|
|
SaveEXRFunc Image::save_exr_func = NULL;
|
|
|
|
|
|
|
|
+SavePNGBufferFunc Image::save_png_buffer_func = NULL;
|
|
|
|
+
|
|
void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel) {
|
|
void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel) {
|
|
|
|
|
|
uint32_t ofs = (p_y * width + p_x) * p_pixelsize;
|
|
uint32_t ofs = (p_y * width + p_x) * p_pixelsize;
|
|
@@ -1898,6 +1900,14 @@ Error Image::save_png(const String &p_path) const {
|
|
return save_png_func(p_path, Ref<Image>((Image *)this));
|
|
return save_png_func(p_path, Ref<Image>((Image *)this));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+PoolVector<uint8_t> Image::save_png_to_buffer() const {
|
|
|
|
+ if (save_png_buffer_func == NULL) {
|
|
|
|
+ return PoolVector<uint8_t>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return save_png_buffer_func(Ref<Image>((Image *)this));
|
|
|
|
+}
|
|
|
|
+
|
|
Error Image::save_exr(const String &p_path, bool p_grayscale) const {
|
|
Error Image::save_exr(const String &p_path, bool p_grayscale) const {
|
|
|
|
|
|
if (save_exr_func == NULL)
|
|
if (save_exr_func == NULL)
|
|
@@ -2728,6 +2738,7 @@ void Image::_bind_methods() {
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("load", "path"), &Image::load);
|
|
ClassDB::bind_method(D_METHOD("load", "path"), &Image::load);
|
|
ClassDB::bind_method(D_METHOD("save_png", "path"), &Image::save_png);
|
|
ClassDB::bind_method(D_METHOD("save_png", "path"), &Image::save_png);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("save_png_to_buffer"), &Image::save_png_to_buffer);
|
|
ClassDB::bind_method(D_METHOD("save_exr", "path", "grayscale"), &Image::save_exr, DEFVAL(false));
|
|
ClassDB::bind_method(D_METHOD("save_exr", "path", "grayscale"), &Image::save_exr, DEFVAL(false));
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("detect_alpha"), &Image::detect_alpha);
|
|
ClassDB::bind_method(D_METHOD("detect_alpha"), &Image::detect_alpha);
|