А в GIF наоборот сохраняется без альфы, хотя она там возможна, даже если задаю формат битмапа PixelFormat32bppARGB.
Вот весь код:
Код:
- Код: Выделить всё
Public Sub SaveToFile(fName As String, fFormat As SR2D_FileFormat, Optional ByVal JPGQuality As Long = 80)
Dim tSI As GdiplusStartupInput
Dim Res As Long
Dim GDIP As Long
Dim Bmp As Long
Dim tEncoder As CLSID
Dim tParams As EncoderParameters
Dim sType As String
tSI.GdiplusVersion = 1
Res = GdiplusStartup(GDIP, tSI)
If Res = 0 Then
Res = GdipCreateBitmapFromScan0(Width, Height, Width * 4, PixelFormat32bppRGB, cBuf(0), Bmp)
If Res = 0 Then
Select Case fFormat
Case ffBMP: sType = "{557CF400-1A04-11D3-9A73-0000F81EF32E}"
Case ffJPG: sType = "{557CF401-1A04-11D3-9A73-0000F81EF32E}"
tParams.count = 1
tParams.Parameter.NumberOfValues = 1
tParams.Parameter.type = 4
tParams.Parameter.value = VarPtr(JPGQuality)
CLSIDFromString StrPtr("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"), tParams.Parameter.GUID
Case ffGIF: sType = "{557CF402-1A04-11D3-9A73-0000F81EF32E}"
Case ffPNG: sType = "{557CF406-1A04-11D3-9A73-0000F81EF32E}"
End Select
CLSIDFromString StrPtr(sType), tEncoder
Res = GdipSaveImageToFile(Bmp, StrPtr(fName), tEncoder, tParams)
GdipDisposeImage Bmp
End If
GdiplusShutdown GDIP
End If
End Sub
Подскажите решение. Где я что-то не учёл?