MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / initialize_data

Method initialize_data

core/io/image.cpp:2182–2206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2180}
2181
2182void Image::initialize_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format) {
2183 ERR_FAIL_COND_MSG(p_width <= 0, vformat("The Image width specified (%d pixels) must be greater than 0 pixels.", p_width));
2184 ERR_FAIL_COND_MSG(p_height <= 0, vformat("The Image height specified (%d pixels) must be greater than 0 pixels.", p_height));
2185 ERR_FAIL_COND_MSG(p_width > MAX_WIDTH,
2186 vformat("The Image width specified (%d pixels) cannot be greater than %d pixels.", p_width, MAX_WIDTH));
2187 ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT,
2188 vformat("The Image height specified (%d pixels) cannot be greater than %d pixels.", p_height, MAX_HEIGHT));
2189 ERR_FAIL_COND_MSG(p_width * p_height > MAX_PIXELS,
2190 vformat("Too many pixels for Image. Maximum is %dx%d = %d pixels.", MAX_WIDTH, MAX_HEIGHT, MAX_PIXELS));
2191 ERR_FAIL_INDEX_MSG(p_format, FORMAT_MAX, vformat("The Image format specified (%d) is out of range. See Image's Format enum.", p_format));
2192
2193 int mm = 0;
2194 int64_t size = _get_dst_image_size(p_width, p_height, p_format, mm, p_use_mipmaps ? -1 : 0);
2195 data.resize(size);
2196
2197 {
2198 uint8_t *w = data.ptrw();
2199 memset(w, 0, size);
2200 }
2201
2202 width = p_width;
2203 height = p_height;
2204 mipmaps = p_use_mipmaps;
2205 format = p_format;
2206}
2207
2208void Image::initialize_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data) {
2209 ERR_FAIL_COND_MSG(p_width <= 0, vformat("The Image width specified (%d pixels) must be greater than 0 pixels.", p_width));

Callers 15

_updateMethod · 0.80
_update_textureMethod · 0.80
bakeMethod · 0.80
onImageMethod · 0.80
_serialize_materialsMethod · 0.80
test_gltf_images.hFile · 0.80
bakeMethod · 0.80
convert_to_imageMethod · 0.80
resizeMethod · 0.80
create_emptyMethod · 0.80
create_from_dataMethod · 0.80

Calls 11

vformatFunction · 0.85
is_digitFunction · 0.85
CLAMPFunction · 0.85
replace_charMethod · 0.80
to_intMethod · 0.80
get_slicecMethod · 0.80
sizeMethod · 0.65
ColorClass · 0.50
resizeMethod · 0.45
ptrwMethod · 0.45
getptrMethod · 0.45

Tested by

no test coverage detected