summaryrefslogtreecommitdiff
path: root/modules/svg/image_loader_svg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/svg/image_loader_svg.cpp')
-rw-r--r--modules/svg/image_loader_svg.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index 7f91908a33..e9d30d015a 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -94,10 +94,10 @@ void ImageLoaderSVG::set_convert_colors(Dictionary *p_replace_color) {
}
}
-Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors) {
+Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const Vector<uint8_t> *p_data, float p_scale, bool upsample, bool convert_colors) {
NSVGimage *svg_image;
- PoolVector<uint8_t>::Read src_r = p_data->read();
- svg_image = nsvgParse((char *)src_r.ptr(), "px", 96);
+ const uint8_t *src_r = p_data->ptr();
+ svg_image = nsvgParse((char *)src_r, "px", 96);
if (svg_image == NULL) {
ERR_PRINT("SVG Corrupted");
return ERR_FILE_CORRUPT;
@@ -115,14 +115,13 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
const int h = (int)(svg_image->height * p_scale * upscale);
ERR_FAIL_COND_V_MSG(h > Image::MAX_HEIGHT, ERR_PARAMETER_RANGE_ERROR, vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max height.", rtos(p_scale)));
- PoolVector<uint8_t> dst_image;
+ Vector<uint8_t> dst_image;
dst_image.resize(w * h * 4);
- PoolVector<uint8_t>::Write dw = dst_image.write();
+ uint8_t *dw = dst_image.ptrw();
- rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw.ptr(), w, h, w * 4);
+ rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw, w, h, w * 4);
- dw.release();
p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image);
if (upsample) {
p_image->shrink_x2();
@@ -136,10 +135,10 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample, bool convert_colors) {
size_t str_len = strlen(p_svg_str);
- PoolVector<uint8_t> src_data;
+ Vector<uint8_t> src_data;
src_data.resize(str_len + 1);
- PoolVector<uint8_t>::Write src_w = src_data.write();
- memcpy(src_w.ptr(), p_svg_str, str_len + 1);
+ uint8_t *src_w = src_data.ptrw();
+ memcpy(src_w, p_svg_str, str_len + 1);
return _create_image(p_image, &src_data, p_scale, upsample, convert_colors);
}
@@ -147,11 +146,11 @@ Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *p
Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
uint32_t size = f->get_len();
- PoolVector<uint8_t> src_image;
+ Vector<uint8_t> src_image;
src_image.resize(size + 1);
- PoolVector<uint8_t>::Write src_w = src_image.write();
- f->get_buffer(src_w.ptr(), size);
- src_w.ptr()[size] = '\0';
+ uint8_t *src_w = src_image.ptrw();
+ f->get_buffer(src_w, size);
+ src_w[size] = '\0';
return _create_image(p_image, &src_image, p_scale, 1.0);
}