Resize an Image using Callback Functions

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

indianahorst
Posts: 1
Joined: Tue Dec 14, 2004 6:55 am
Location: Germany

Resize an Image using Callback Functions

Post by indianahorst »

Hi,
I would like to resize an Image using the callback functions.
What values do I have do enter in MODE and FLAGS in the Function gflResize

Here is my code, but the size of the picture isn't changed:

Code: Select all

Private Sub Form_Load()
  Dim GflBitmap As GFL_BITMAP
  Dim PtrBitmap As Long
  Dim GflLoadParams As GFL_LOAD_PARAMS
  Dim GflSaveParams As GFL_SAVE_PARAMS
  Dim GflInfo As GFL_FILE_INFORMATION
  Dim Error As Integer
  
  Dim lngHeigt As Long
  Dim lngWidth As Long
  Dim lngMethod As Long
  
  gflLibraryInit 'Initialize the library
  gflGetDefaultLoadParams GflLoadParams 'Gets default parameters for loading
  gflGetDefaultSaveParams GflSaveParams 'Gets default parameters for saving
  
  Error = gflLoadBitmap("C:\Bilder\Rally.bmp", PtrBitmap, GflLoadParams, GflInfo) 'Load bitmap in memory
  If Error = GFL_NO_ERROR Then 'Si aucune erreur
    extGetGflBitmapFromPtr PtrBitmap, GflBitmap 'Get the picture data
    lngHeigt = 691
    lngWidth = 1000
    lngMethod = 19
    Debug.Print gflResize(GflBitmap, PtrBitmap, lngWidth, lngHeigt, lngMethod, 0)
    Debug.Print GflBitmap.Width
    
    With GflSaveParams.Callbacks
    .Write = extFarProc(AddressOf WRITE_WriteFunction) 'Set the CallBacks
    .Tell = extFarProc(AddressOf WRITE_TellFunction)
    .Seek = extFarProc(AddressOf WRITE_SeekFunction)
    End With
    
    GflSaveParams.FormatIndex = gflGetFormatIndexByName("jpeg") 'Set the writing format
    GflSaveParams.Quality = 70
    
    Error = gflSaveBitmapIntoHandle(VarPtr(SData), GflBitmap, GflSaveParams) 'Write the file in memory using the SData strucutre (copy of SAVE_DATA)
    If Error = GFL_NO_ERROR Then
      extSaveFile "C:\Bilder\Rally.jpg", SData 'If no error, save the picture
      Text1.text = "File saved !"
      gflMemoryFree SData.Data 'Free SData
    End If
    
    gflFreeBitmapData GflBitmap 'Free bitmap
  End If
  
  If Error <> GFL_NO_ERROR Then MsgBox "Error : " & extGetStr(gflGetErrorString(Error)) & " (" & Error & ")" 'If no error, display it
  
  gflLibraryExit 'Quit library
End Sub
User avatar
xnview
Author of XnView
Posts: 44922
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Resize an Image using Callback Functions

Post by xnview »

indianahorst wrote:Hi,
I would like to resize an Image using the callback functions.
What values do I have do enter in MODE and FLAGS in the Function gflResize
gflResize accept GFL_RESIZE_QUICK or GFL_RESIZE_BILINEAR as method, flags is not used.
Pierre.