I've observed that the default jpg save quality using GDI+'s GdipSaveImageToFile leaves something to be desired. No trouble, I thought, I'll just adjust the quality.
I've got code to demonstrate the problem. The program is very long, but I believe I've enclosed enough code to show all relevant portions...
From the top, Types:
A couple of constants I'm using:
And finally, the code in question, which crashes on "...has encountered a problem..."
Now, I know my img, fileSpec, sEncloderClsid are okay. In fact, this works perfectly well if I do either one of the following:
1. Drop the eps reference alltogether when calling GDIpSaveImageToFile or;
2. Change eps.pCount = 0
This tells me that there is something wrong with what I am putting into the eps structure. Thus, whatever is wrong must be in the above lines of code.
Any thoughts?
I've got code to demonstrate the problem. The program is very long, but I believe I've enclosed enough code to show all relevant portions...
From the top, Types:
Code:
TYPE EncoderParameter pGuid AS GUID NumberOfValues AS DWORD dwType AS DWORD Value AS DWORD END TYPE TYPE EncoderParameters pCount AS DWORD Parameter(0) AS EncoderParameter END TYPE
Code:
$EncoderQuality = GUID$("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}") %EncoderParameterValueTypeLong = 4
Code:
DIM eps AS EncoderParameters eps.pCount = 1 eps.Parameter(0).pGuid = $EncoderQuality eps.Parameter(0).dwType = %EncoderParameterValueTypeLong eps.Parameter(0).NumberOfValues = 1 dwQuality& = 85 eps.Parameter(0).Value = VARPTR(dwQuality&) r& = GdipSaveImageToFile(img, FileSpec, sEncoderClsid, eps)
1. Drop the eps reference alltogether when calling GDIpSaveImageToFile or;
2. Change eps.pCount = 0
This tells me that there is something wrong with what I am putting into the eps structure. Thus, whatever is wrong must be in the above lines of code.
Any thoughts?
Comment