Announcement

Collapse
No announcement yet.

GDI+ Jpeg Save Quality

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Philip Zeller
    replied
    Perfect

    Perfect solution, didn't think of that DECLARE not passing byref.

    Of course, things are always plain as day in hindsight.

    Thanks!

    Leave a comment:


  • José Roca
    replied
    Change it to

    Code:
    DECLARE FUNCTION GdipSaveImageToFile         LIB "gdiplus.dll" ALIAS "GdipSaveImageToFile"         (BYVAL lpImage AS DWORD, BYVAL flname AS STRING, clsidEncoder AS GUID, BYREF EncoderParams AS encoderParameters) AS LONG

    Leave a comment:


  • Philip Zeller
    replied
    Code:
    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

    Leave a comment:


  • José Roca
    replied
    I think that you are filling the UDT correctly, but can you let us know which DECLARE are you using for GdipSaveImageToFile?

    Leave a comment:


  • Philip Zeller
    started a topic GDI+ Jpeg Save Quality

    GDI+ Jpeg Save Quality

    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:

    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
    A couple of constants I'm using:

    Code:
    $EncoderQuality = GUID$("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}")
    %EncoderParameterValueTypeLong = 4
    And finally, the code in question, which crashes on "...has encountered a problem..."

    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)
    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?
Working...
X