Comments (1)
This is the intended behavior. Quoting from the header file:
If req_comp is non-zero, *comp has the number of components that would
have been output otherwise. E.g. if you set req_comp to 4, you will always
get RGBA output, but you can check *comp to easily see if it's opaque.
-Fabian
On Apr 3, 2015 08:51, "Kyle Swanson" [email protected] wrote:
Forcing the number of components per pixel doesn't seem to be working with
stb_image.h. Calling stbi_load() with any number between 0 .. 4 always
results in 3. See code below.#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
int main(int argc, char **argv) {
const char *inputFile = argv[1];
const char *outputFile = argv[2];
int x,y,n;
unsigned char *data = stbi_load(inputFile, &x, &y, &n, 1); //This should force just one (gray) component per pixel.if (!data) { fprintf(stderr, "Couldn't load image.\n"); return (-1); } printf("%d\n", n); //This prints `3`, should print 1. stbi_image_free(data); return 0;
}
—
Reply to this email directly or view it on GitHub
#103.
from stb.
Related Issues (20)
- Is the "DETAILED USAGE" section of `stb_truetype.h` correct/updated? HOT 3
- A way to reuse a buffer when reading `.gif` files HOT 2
- GCC warnings for the hmdel macro HOT 1
- stb_sprintf: not working with 'j' 'z' modifiers
- [text.txt](https://github.com/nothings/stb/files/13457062/text.txt)
- Segmentation fault when load an corruption pictures in stbi_load_from_memory HOT 2
- stb_image incorrectly sees png as 16bit. HOT 5
- Completion of error handling
- Request for CMakeLists.txt Integration for Improved Build System
- stb_truetype.h: letter T has rasterization artefacts for Roboto-Regular.ttf HOT 3
- [stb-vorbis] Some multi-channel OGG Vorbis files gets wrongly decoded
- Two errors for use of uninitialized memory
- Long double support
- stb_truetype: GPOS advance always 0 (while GPOS and KERN tables exist), while KERN works fine
- stb_truetype: stbtt_GetCodepointHMetrics() outputs weird advanceWidth values after being called several times HOT 1
- stb_image_resize2: assert/crash on resizing 2x2 to 1x1 images with wrap HOT 5
- stb_image: loading of an invalid JPEG image succeeds
- problem in reading libraries HOT 1
- 16 bit PNG Support
- Array Out Of Bounds - stb_image_resize2.h HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stb.