I am new here and i hope i do not make any mistakes with this question.
I try to change a GIF-File that contains transparency. The problem lies within the following code:
Expand|Select|Wrap|Line Numbers
- ' Open a gif with transparency
- Dim nBm As Bitmap = New Bitmap("C:\Temp\TestTransparent.gif")
- ' Create a new bitmap with the same size
- Dim nResult As Bitmap = New Bitmap(nBm.Width, nBm.Height)
- ' Get a graphics object
- Dim nGr As Graphics = Graphics.FromImage(nResult)
- ' Draw the old bitmap to the new one
- nGr.DrawImage(nBm, New Point(0, 0))
- ' Make black transparent
- nResult.MakeTransparent(Color.Black)
- ' save the whole thing as gif
- nResult.Save("C:\Temp\TestTransparent_Neu.gif", Imaging.ImageFormat.Gif)
The purpose of the code at the end should be to reduce the gif in size. So i have to build a new bitmap out of the old.
I searched for "gif transparent", "transparent black", DrawImage transparent" and found nothing to help me on. Also google is not my friend in this case. Many tips, most for java or browsers.
I post this in the .net-forums. I dont think that this is a VB- or C#-issue. Correct me if i am wrong.
Greetings
Alex