Sign in to follow this  
parroteye

Failing to load correctly some images with stb_image

Recommended Posts

Hi!

 

Up to now I have only been using dds, I am now trying to load some jpg and png textures to test something, but I have had mixed luck with stb 

 

All I do to load is 

stbi_load(path, &w, &h, &c, STBI_rgb_alpha); 

Now some textures load ok,

Nsttahp.png

 

some load with a strange stripey pattern

bKWRXo2.png

 

Stripey pattern that is not visible in the source image.

 

I tried STBI_rgb for the one that loaded strangely, but the result is even more wrong in most cases, like I would expect actually... 

 

What am I doing wrong? The texture resource is created in all cases with DXGI_FORMAT_R8G8B8A8_UNORM

 

thanks

 

Jacques

 

Share this post


Link to post
Share on other sites

stb_image is documented to not have complete support for all JPG and PNG formats: have a look at the top of the header file for notes on this.

However I suspect that is isn't your problem (the formats it doesn't handle are unlikely to be met in common usage) but rather that stb_image is loading the textures correctly and that your problem is actually happening during the transfer of the image data to Direct3D.  You'll need to talk a little about how you're doing that before I can say more.

Share this post


Link to post
Share on other sites

stb_image is documented to not have complete support for all JPG and PNG formats: have a look at the top of the header file for notes on this.

However I suspect that is isn't your problem (the formats it doesn't handle are unlikely to be met in common usage) but rather that stb_image is loading the textures correctly and that your problem is actually happening during the transfer of the image data to Direct3D.  You'll need to talk a little about how you're doing that before I can say more.

 

It was indeed that! After posting I googled a bit, to find that comp is not the number of components of the output data like I thought it was! 

Share this post


Link to post
Share on other sites

if you think you have l0oaded texture properly then you need to check your rendering code perspective projection etc/ and see if you are even drawing it properly

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this