en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en de en en en en nl en en en en en en en en en en en en en en en en en en en de en en en en en nl en en en en en en de en en en en nl en en en en en en en en en en en nl en en en en en en en en de en en en en nl en en en en en en en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in PowerBASIC for Windows only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
Join Date: Mar 2008
GDI+ Jpeg Save Quality
19 Feb 2009, 02:04 PM
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:
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
A couple of constants I'm using:
And finally, the code in question, which crashes on "...has encountered a problem..."
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)
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 altogether 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.
Join Date: Mar 2004
19 Feb 2009, 03:44 PM
I think that you are filling the UDT correctly, but can you let us know which DECLARE are you using for GdipSaveImageToFile?
Join Date: Mar 2008
19 Feb 2009, 03:48 PM
DECLARE FUNCTION GdipSaveImageToFile LIB "gdiplus.dll" ALIAS "GdipSaveImageToFile" (BYVAL lpImage AS DWORD, BYVAL flname AS STRING, clsidEncoder AS GUID, OPT BYVAL EncoderParams AS encoderParameters) AS LONG
Join Date: Mar 2004
19 Feb 2009, 04:14 PM
DECLARE FUNCTION GdipSaveImageToFile LIB "gdiplus.dll" ALIAS "GdipSaveImageToFile" (BYVAL lpImage AS DWORD, BYVAL flname AS STRING, clsidEncoder AS GUID, [B]BYREF EncoderParams AS encoderParameters[/B]) AS LONG
Join Date: Mar 2008
19 Feb 2009, 04:20 PM
Perfect solution, didn't think of that DECLARE not passing byref.
Of course, things are always plain as day in hindsight.
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 03:44 AM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.