MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__convert_8_to_16

Function stbi__convert_8_to_16

lite/example/cpp_example/mge/cv/stb_image.h:1225–1241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1223}
1224
1225static stbi__uint16* stbi__convert_8_to_16(stbi_uc* orig, int w, int h, int channels) {
1226 int i;
1227 int img_len = w * h * channels;
1228 stbi__uint16* enlarged;
1229
1230 enlarged = (stbi__uint16*)stbi__malloc(img_len * 2);
1231 if (enlarged == NULL)
1232 return (stbi__uint16*)stbi__errpuc("outofmem", "Out of memory");
1233
1234 for (i = 0; i < img_len; ++i)
1235 enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high
1236 // and low byte, maps
1237 // 0->0, 255->0xffff
1238
1239 STBI_FREE(orig);
1240 return enlarged;
1241}
1242
1243static void stbi__vertical_flip(void* image, int w, int h, int bytes_per_pixel) {
1244 int row;

Callers 1

Calls 1

stbi__mallocFunction · 0.85

Tested by

no test coverage detected