SFML community forums
Bindings - other languages => DotNet => Topic started by: renner96 on July 31, 2009, 09:05:14 pm
-
Hi,
i want to convert a graphics.image, wich I converted with the following code to a byte array , into a SFML.Graphics.Image.
Public Function imageToByteArray(ByVal imageIn As System.Drawing.Image) As Byte()
Dim ms As MemoryStream = New MemoryStream()
imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif)
Return ms.ToArray()
End Function
I hope you can help me. Can i do it without the array?
Thank You
renner96
PS: My English isn“t very good. I`m only on the 7th grade on a German grammar school.
//edit: i tried it with a memorystream, too, but i got an exeption: Failed to load image from memory
//edit2: is there a function to make the image of an graphics.bitmap???
-
Can somebody change the following code that it could be used with sfml directly
Private Shared Function RotateImageByAngle(ByVal oldBitmap As System.Drawing.Image, ByVal angle As Single) As Bitmap
Dim newBitmap As Bitmap
Dim graphics1 As Graphics
If oldBitmap.Width >= oldBitmap.Height Then
newBitmap = New Bitmap(oldBitmap.Width * 2, oldBitmap.Width * 2)
Else
newBitmap = New Bitmap(oldBitmap.Height * 2, oldBitmap.Height * 2)
End If
graphics1 = Graphics.FromImage(newBitmap)
graphics1.TranslateTransform(CSng(oldBitmap.Width) / 2, CSng(oldBitmap.Height) / 2)
graphics1.RotateTransform(angle)
graphics1.TranslateTransform(-CSng(oldBitmap.Width) / 2, -CSng(oldBitmap.Height) / 2)
graphics1.DrawImage(oldBitmap, New Point(0, 0))
Return newBitmap
End Function
PS: the code is the reason, why i wanted to change the image into sfml
-
The Sfml.Image class take a parameter for a stream and the MemoryStream is also valid. So you don't need to use a byte array.