SFML community forums

Help => Graphics => Topic started by: WilliamK2H on January 25, 2020, 12:04:18 am

Title: Failed to load texture from memory
Post by: WilliamK2H on January 25, 2020, 12:04:18 am
I'm using sfmlnet-graphics-2 version 2.2.0.0.

A player of my game is running with specs:
Quote
i3 2350m with intel hd 3000 integrated 6gb ram

He is successfull in loading the first image file that is 7mb but fails on all others (ranging from 1mb to 26mb). He gets the following error:
 SFML.LoadingFailedException: Failed to load texture from memory
   at SFML.Graphics.Texture..ctor(Image image, IntRect area)
   at SFML.Graphics.Texture..ctor(Image image)
   at K2HGame.SFML_Utils.TextureFromDecryptedFile(Byte[] buffer)
   at K2HGame.modDirectX.InitSurfaces()

And the code for TextureFromDecryptedFile is:
    Public Shared Function TextureFromDecryptedFile(buffer As Byte()) As Graphics.Texture
        Dim image As Graphics.Image
        image = New Graphics.Image(New IO.MemoryStream(buffer))
        image.CreateMaskFromColor(New Graphics.Color(0, 0, 0)) 'Setting alpha to 0 for all pixels with 0,0,0 rgb
        Return New Graphics.Texture(image)
    End Function

So what I'm looking for is what could be the cause of this issue. Could it be my coding that is bad? I do encrypt all graphics files, and use this to decrypt them:
(click to show/hide)

So what I do is basically decrypt the image file and then load it into the texture:
m_Paperdoll = SFML_Utils.TextureFromDecryptedFile(DecryptGfx.DecryptFile(filename & "paperoll.encrypt", bytKey, bytIV))

Any and all ideas are appreciated.
Title: Re: Failed to load texture from memory
Post by: WilliamK2H on January 25, 2020, 10:51:12 pm
It seems integrated hd 3000 do not support images larger than 4096x4096px. And I'm pretty sure that is the issue.
Title: Re: Failed to load texture from memory
Post by: Hapax on January 29, 2020, 09:38:26 pm
SFML can give you information about the maximum available texture size:
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Texture.php#a0bf905d487b104b758549c2e9e20a3fb

Although I'm not sure exactly how it's done in .NET, it should be there somewhere!