MCPcopy Create free account
hub / github.com/BinomialLLC/basis_universal / encode_etc1s

Function encode_etc1s

example/example.cpp:102–137  ·  view source on GitHub ↗

This LDR example function uses the basis_compress() C-style function to compress a ETC1S .KTX2 file.

Source from the content-addressed store, hash-verified

100
101// This LDR example function uses the basis_compress() C-style function to compress a ETC1S .KTX2 file.
102static bool encode_etc1s()
103{
104 const uint32_t W = 512, H = 512;
105
106 image img(W, H);
107 for (uint32_t y = 0; y < H; y++)
108 for (uint32_t x = 0; x < W; x++)
109 img(x, y).set(0, y >> 1, x >> 1, ((x ^ y) & 1) ? 255 : 0);
110
111 basisu::vector<image> source_images;
112 source_images.push_back(img);
113
114 size_t file_size = 0;
115 uint32_t quality_level = 255;
116
117 // basis_compress() is a simple wrapper around the basis_compressor_params and basis_compressor classes.
118 void* pKTX2_data = basis_compress(
119 basist::basis_tex_format::cETC1S,
120 source_images,
121 quality_level | cFlagSRGB | cFlagGenMipsClamp | cFlagThreaded | cFlagPrintStats | cFlagDebug | cFlagPrintStatus | cFlagUseOpenCL, 0.0f,
122 &file_size,
123 nullptr);
124
125 if (!pKTX2_data)
126 return false;
127
128 if (!write_data_to_file("test_etc1s.ktx2", pKTX2_data, file_size))
129 {
130 basis_free_data(pKTX2_data);
131 return false;
132 }
133
134 basis_free_data(pKTX2_data);
135
136 return true;
137}
138
139// This LDR example function uses the basis_compress() C-style function to compress a UASTC LDR .KTX2 file.
140static bool encode_uastc_ldr()

Callers 1

mainFunction · 0.85

Calls 5

basis_compressFunction · 0.85
write_data_to_fileFunction · 0.85
basis_free_dataFunction · 0.85
setMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected