I use GDI api "GdipSaveImageToFile" to save a picture as JPEG format, but
even i use 100 as the quality parameter, the saved jpeg file's quality is
very low.
the code i use:
Public Sub SaveJPG(ByVal pict As Long, ByVal filename As String, Optional
ByVal quality As Byte = 100)
Dim tSI As GdiplusStartupInput
Dim lRes As Long
Dim lGDIP As Long
Dim lBitmap As Long
Dim myQuality As Byte
myQuality = 100
' Initialize GDI+
tSI.GdiplusVersion = 1
lRes = GdiplusStartup(lGDIP, tSI)
If lRes = 0 Then
' Create the GDI+ bitmap
' from the image handle
lRes = GdipCreateBitmapFromHBITMAP(pict, 0, lBitmap)
If lRes = 0 Then
Dim tJpgEncoder As GUID
Dim tParams As EncoderParameters
' Initialize the encoder GUID
CLSIDFromString StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), _
tJpgEncoder
' Initialize the encoder parameters
tParams.Count = 1
With tParams.Parameter ' Quality
' Set the Quality GUID
CLSIDFromString StrPtr("{1D5BE4B5-FA4A-452D-9CDD-5DB3505E7EB}"),
.GUID
.NumberOfValues = 1
.Type = 4
.Value = VarPtr(myQuality)
End With
' Save the image
lRes = GdipSaveImageToFile(lBitmap, StrPtr(filename), tJpgEncoder,
tParams)
' Destroy the bitmap
GdipDisposeImage lBitmap
End If
' Shutdown GDI+
GdiplusShutdown lGDIP
End If
End Sub
The code is in a COM+ project, and i use the COM on a windows2003 server.
and for network speed reason, i logon the server by remote desktop,i have
set the "color" property on "display" tab of the desktop as 256. when i set
the "color" property as 24Bit, the saved picture's quality is ok. Strange?
the quality of GDI is based on the desktop of windows?
Many thanks for any help.