Announcement

Collapse
No announcement yet.

How to retain Exif data with GDI+?

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

  • How to retain Exif data with GDI+?

    When I save an JPEG image that has Exif parameters with GDI+ I loose the Exif data. Any idea how can we retain it in the saved image?

    Regards,

    Peter Redei

  • #2
    Never mind

    Never mind, I got it...

    Peter Redei

    Comment


    • #3
      Hi Peter,

      Can you share what the problem / solution was? It may be of use to others in the same situation
      Dominic
      Manchester UK

      Comment


      • #4
        Here is some code

        Dominic,

        I thought the solution was quite obvious and only I did not know it, so I did not submit any code. For you and for those to whom it is helpful...
        Code:
        $EncoderSaveFlag          = GUID$("{292266FC-AC40-47BF-8CFC-A85B89A655DE}")
        %EncoderParameterValueTypeLong = 4 
        %EncoderValueFlush                     = 20
        
        TYPE EncoderParameter
           pGuid AS GUID             '  // GUID of the parameter
           NumberOfValues AS DWORD   '  // Number of the parameter values
           dwType AS DWORD           '  // Value type, like ValueTypeLONG  etc.
           Value AS DWORD            '  // A pointer to the parameter values
        END TYPE
        TYPE EncoderParameters
           Count AS DWORD                    ' // Number of parameters in this structure
           Parameter(0) AS EncoderParameter  ' // Parameter values - variable-length array
        END TYPE 
        
        DECLARE FUNCTION GDI_GdipSaveImageToFile(BYVAL lpImage AS DWORD, BYVAL flname AS STRING, BYREF clsidEncoder AS GUID, OPTIONAL BYREF EncoderParams AS EncoderParameters) AS LONG
        
        FUNCTION GdipSaveImageToFile(BYVAL lpImage AS DWORD, BYVAL flname AS STRING, BYREF clsidEncoder AS GUID, OPTIONAL BYREF EncoderParams AS EncoderParameters) AS LONG
            LOCAL procAddr   AS DWORD
            LOCAL hRes       AS LONG
            LOCAL eps AS EncoderParameters
            LOCAL ep AS EncoderParameter
            LOCAL parameterValue AS DWORD
        
        
            eps.Count = 1
            ' // Initialize the one EncoderParameter object.
            eps.Parameter(0).pGuid = $EncoderSaveFlag
            eps.Parameter(0).dwType = %EncoderParameterValueTypeLong
            eps.Parameter(0).NumberOfValues = 1
            eps.Parameter(0).Value = VARPTR(parameterValue)
            parameterValue = %EncoderValueFlush
        
            IF hGdiLIB = 0 THEN
                FUNCTION = 0
            ELSE
                procAddr = GetProcAddress(hGdiLIB, "GdipSaveImageToFile")
                CALL DWORD procAddr USING GDI_GdipSaveImageToFile(lpImage, flname, clsidEncoder, eps) TO hRes
                FUNCTION = hRes
            END IF
        END FUNCTION
        My problem was that I passed %NULL instead of the eps structure.


        Regards,


        Peter Redei

        Comment

        Working...
        X