Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Failed to load texture from memory  (Read 2275 times)

0 Members and 1 Guest are viewing this topic.

WilliamK2H

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Failed to load texture from memory
« 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.
« Last Edit: January 25, 2020, 12:41:40 am by WilliamK2H »

WilliamK2H

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • Email
Re: Failed to load texture from memory
« Reply #1 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Failed to load texture from memory
« Reply #2 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!
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*