I need to create a bitmap object that either preserves the alpha channel of a png or adds one if the png has no alpha channel. This:
Will alter the colors or alpha values. I use the Image.Save method described here to convert pngs to bmps:
http://msdn.microsoft.com/en-us/library/ytz20d80.aspx
Now I just need to convert pngs to 32bppArgb bitmaps instead.
The msdn example saves to a file, but I save to a stream instead. There is only one ImageFormat.Bmp so what do I do?
This is the 'GetEncoderInfo' function from msdn:
Can I write that to convert to 32bppArgb bitmap instead?
Dim a = New Bitmap( _
My.Application.Info.DirectoryPath & "\a.png")
Dim b As New Bitmap(a)
Will alter the colors or alpha values. I use the Image.Save method described here to convert pngs to bmps:
http://msdn.microsoft.com/en-us/library/ytz20d80.aspx
Now I just need to convert pngs to 32bppArgb bitmaps instead.
The msdn example saves to a file, but I save to a stream instead. There is only one ImageFormat.Bmp so what do I do?
This is the 'GetEncoderInfo' function from msdn:
Private Shared Function GetEncoderInfo(ByVal format As ImageFormat) As ImageCodecInfo
Dim j As Integer
Dim encoders() As ImageCodecInfo
encoders = ImageCodecInfo.GetImageEncoders()
j = 0
While j < encoders.Length
If encoders(j).FormatID = format.Guid Then
Return encoders(j)
End If
j += 1
End While
Return Nothing
End Function
Can I write that to convert to 32bppArgb bitmap instead?