| 2180 | } |
| 2181 | |
| 2182 | void 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 | |
| 2208 | void 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)); |
no test coverage detected