MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / astc_img_from_unorm8x4_array

Function astc_img_from_unorm8x4_array

Source/astcenccli_image.cpp:231–255  ·  view source on GitHub ↗

See header for documentation. */

Source from the content-addressed store, hash-verified

229
230/* See header for documentation. */
231astcenc_image_ptr astc_img_from_unorm8x4_array(
232 const uint8_t* data,
233 unsigned int dim_x,
234 unsigned int dim_y,
235 bool y_flip
236) {
237 auto img = alloc_image(8, dim_x, dim_y, 1);
238
239 for (unsigned int y = 0; y < dim_y; y++)
240 {
241 uint8_t* data8 = static_cast<uint8_t*>(img->data[0]);
242 unsigned int y_src = y_flip ? (dim_y - y - 1) : y;
243 const uint8_t* src = data + 4 * dim_x * y_src;
244
245 for (unsigned int x = 0; x < dim_x; x++)
246 {
247 data8[(4 * dim_x * y) + (4 * x )] = src[4 * x ];
248 data8[(4 * dim_x * y) + (4 * x + 1)] = src[4 * x + 1];
249 data8[(4 * dim_x * y) + (4 * x + 2)] = src[4 * x + 2];
250 data8[(4 * dim_x * y) + (4 * x + 3)] = src[4 * x + 3];
251 }
252 }
253
254 return img;
255}
256
257/* See header for documentation. */
258std::vector<float> floatx4_array_from_astc_img(

Callers 2

load_png_with_wuffsFunction · 0.85
load_image_with_stbFunction · 0.85

Calls 1

alloc_imageFunction · 0.85

Tested by

no test coverage detected