# Failing to load correctly some images with stb_image

This topic is 592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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,

some load with a strange stripey pattern

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 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 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 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

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013550
×