I'm using sfmlnet-graphics-2 version 2.2.0.0.
A player of my game is running with specs:
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:
Public Shared Function DecryptFile
(strInputFile
As String, bytKey
() As Byte, bytIV
() As Byte) As Byte() Dim inputFile
As System
.IO.FileStream = Nothing Try Dim result
() As Byte = {} inputFile
= New System
.IO.FileStream(strInputFile, FileMode
.Open, FileAccess
.Read) Dim cryptType
As New System
.Security.Cryptography.RijndaelManaged Using ms
= inputFile
Using cs
As New CryptoStream
(ms, cryptType
.CreateDecryptor(bytKey, bytIV
), CryptoStreamMode
.Read) Using ms2
As New MemoryStream
() cs
.CopyTo(ms2
) result
= ms2
.ToArray() End Using End Using End Using inputFile
.Close() Return result
Catch ex
As Exception
MainHandler
.LogException($
"DecryptFile {strInputFile}", ex
) inputFile
?.Close() End Try Return Nothing End Function 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.