MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / alloc_image

Function alloc_image

external/astc-encoder/Source/astcenccli_image.cpp:28–69  ·  view source on GitHub ↗

See header for documentation. */

Source from the content-addressed store, hash-verified

26
27/* See header for documentation. */
28astcenc_image *alloc_image(
29 unsigned int bitness,
30 unsigned int dim_x,
31 unsigned int dim_y,
32 unsigned int dim_z
33) {
34 astcenc_image *img = new astcenc_image;
35 img->dim_x = dim_x;
36 img->dim_y = dim_y;
37 img->dim_z = dim_z;
38
39 void** data = new void*[dim_z];
40 img->data = data;
41
42 if (bitness == 8)
43 {
44 img->data_type = ASTCENC_TYPE_U8;
45 for (unsigned int z = 0; z < dim_z; z++)
46 {
47 data[z] = new uint8_t[dim_x * dim_y * 4];
48 }
49 }
50 else if (bitness == 16)
51 {
52 img->data_type = ASTCENC_TYPE_F16;
53 for (unsigned int z = 0; z < dim_z; z++)
54 {
55 data[z] = new uint16_t[dim_x * dim_y * 4];
56 }
57 }
58 else // if (bitness == 32)
59 {
60 assert(bitness == 32);
61 img->data_type = ASTCENC_TYPE_F32;
62 for (unsigned int z = 0; z < dim_z; z++)
63 {
64 data[z] = new float[dim_x * dim_y * 4];
65 }
66 }
67
68 return img;
69}
70
71/* See header for documentation. */
72void free_image(astcenc_image * img)

Callers 7

load_uncomp_fileFunction · 0.85
print_diagnostic_imagesFunction · 0.85
astcenc_mainFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected