nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.31k stars 7.69k forks source link

Extracting specific channels from an image #1441

Closed daniilvinn closed 1 year ago

daniilvinn commented 1 year ago

Problem In my project, I'm having a bunch of maps and each of their channels are responsive for each specific task. I need to load R, G and B channels separately, as loading gray-scale images is implemented.

Solution I would like to see Adding additional variants into req_comp paramater in "stbi_load()" and "stbi_loadf()" would be a nice feature, for example: "STBI_r", "STBI_b" etc.

Another solution, which in my opinion would work nicely as well Extend API by adding functions like "stbi_extract_r()", "stbi_extract_b()", which will return a pointer to an array of appropriate values.

nothings commented 1 year ago

This is trivial to do by the caller, you're just reshuffling the byte array pixels[3][height][width] to pixels[3][height][width], which is very easy to do by the caller, so it doesn't make any sense to be in the library.