Questions tagged [stb-image]

Single-file public domain (or MIT licensed) library for image loading/decoding from file/memory. Implemented for C/C++ by Sean Barrett.

Single-file public domain (or MIT licensed) library for image loading/decoding from file/memory. Implemented for C/C++ by Sean Barrett.

Resources:

101 questions
5
votes
1 answer

Linux C++ compilation error

I am trying to load images using stb_image.h but I am getting two compiler errors in the version of provided by gcc. I figure that there is probably a compiler option that is needed but I haven't been able to find what it is. Error…
Ceredia
  • 51
  • 4
4
votes
1 answer

What do the parameters of stb_png_to_mem mean?

I am using the stb libraries to load textures on the fly for OpenGL. I'm trying to use the function from stb_image_write.h. I cannot find any documentation on how to properly use the function stbi_write_png_to_mem my code looks like the…
killer
  • 372
  • 1
  • 5
  • 15
3
votes
1 answer

OpenGL distorted texture

I am trying to display a texture, but for some reason it's not shown correctly it's distorted. This is my source code: #include #include #include #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" void…
Martin Chekurov
  • 733
  • 4
  • 15
3
votes
1 answer

stbir_resize_uint8 crashing on memory access

I'm using stb_image to upload an image to the GPU. If I just upload the image with stbi_load I can confirm (nvidia Nsight) that the image is correctly stored in the GPU memory. However, some images I like to resize before I upload the to the GPU.…
Karlovsky120
  • 6,212
  • 8
  • 41
  • 94
3
votes
1 answer

`stbi_failure_reason()` returns no SOI, but file loads

I am loading a png file using stb_image_load. The code looks something like stbi_uc* pixels = stbi_load("textures/viking_room.png", &texWidth, &texHeight, &texChannels, STBI_rgb_alpha); ... if (stbi_failure_reason()) std::cout <<…
Pranav Nachnekar
  • 115
  • 1
  • 10
3
votes
1 answer

PNG saved from OpenGL framebuffer using stbi_write_png is shifted to the right

I have been trying to solve this visual bug for a few days without any success, so I'm asking this question to see if somebody can help me understand what is happening. First I will describe the problem without any code, and then I will present some…
user3266738
  • 477
  • 2
  • 12
3
votes
1 answer

Create bitmap on Java and send it to C++ using JNI and render it by OpenGL, black

On Android, I use JNI to send a string from C++ to Java then draw it to a bitmap then return the byte array back to C++ to draw it to OpenGL, I get a black rectangle . First I create the bitmap in Java by this way: public static byte[]…
2
votes
1 answer

stbi_load() return NULL and "PNG not supported: unknown PNG chunk type" error occurred, when load android internal storage file path

Purpose I am making an Android application with vulkan. I saved bitmap in "texture.png" file in the device internal storage. I want to show this image with vulkan. Then I need to pass image data to c++ somehow. Try I tried below process: pass the…
Saw 000
  • 21
  • 4
2
votes
0 answers

Best way to read file for stbi_load

I'm learning C++ and have been following this learn openGL tutorial. I'm trying to geta texture file and put it into data, but I can't seem to get anything to work. What would be the best way to go about this? unsigned char* data = stbi_load("WHAT…
Dahstroyer
  • 21
  • 1
2
votes
1 answer

Why can glGenerateMipmap(GL_TEXTURE_2D) and setting GL_TEXTURE_MIN_FILTER to GL_LINEAR solve the black texture problem?

I have tried to load an image into an OpenGL texture use stb_image, and here is the code: unsigned int texture; glGenTextures(1, &texture); int width, height, nrChannels; stbi_set_flip_vertically_on_load(true); unsigned char* data =…
L. Swifter
  • 3,179
  • 28
  • 52
2
votes
1 answer

How to use a 2d texture array in opengl

I am trying to load textures into a 2d array and than apply them. But the screen only shows Black. This is my code. Creating Textures. void int loadTexture(char const* path) { glCreateTextures(GL_TEXTURE_2D_ARRAY, 1, &textureID); int…
Summit
  • 2,112
  • 2
  • 12
  • 36
2
votes
1 answer

Writing to a 3D Texture Using Framebuffers and Saving as Image

I'm trying to generate a 3D worley noise texture for some volumetric effects. I am simply generating a set of random points and for each fragment, I will find the closest point and get the distance between the fragment and the pixel. The distance is…
Kihz
  • 81
  • 1
  • 8
2
votes
2 answers

Stbi loading errors

When I try to use stbi to load an image all I get is this error: 1>Renderer.obj : error LNK2005: "void __cdecl stbi__unpremultiply_on_load_thread(int)" (?stbi__unpremultiply_on_load_thread@@YAXH@Z) already defined in LoadFile.obj 1>Main.obj : error…
2
votes
1 answer

Why the width of the opengl viewport I set is smaller and the reading pixels are not aligned?

code show as below(use the demo from enter link description here)to render glyph Luint rbcolor; glGenRenderbuffers(1, &rbcolor); glBindRenderbuffer(GL_RENDERBUFFER, rbcolor); glRenderbufferStorage(GL_RENDERBUFFER, GL_RED, width,…
ziwei wang
  • 21
  • 2
2
votes
2 answers

Can i write a JPG image to memory with stb_image_write.h?

I want to get the result from stbir_resize_uint8 (from https://github.com/nothings/stb/blob/master/stb_image_resize.h) compress it to JPG and store that to a buffer without saving it to disk. I already have the result from stbir_resize_uint8 as a…
Dave
  • 93
  • 2
  • 9
1
2 3 4 5 6 7