Author Topic: FreeImage with DLLC  (Read 2175 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2747
    • ScriptBasic Open Source Project
FreeImage with DLLC
« on: March 12, 2013, 01:13:31 PM »
I converted one of my old FreeImage SB examples using GTK-Server to DLLC. I have attached a new DLLC that handles the weird FreeImage function names. (direct access without going through a wrapper)

Code: OxygenBasic
  1. ' FreeImage Example
  2.  
  3. DECLARE SUB DLLC_File ALIAS "dllfile" LIB "DLLC"
  4. DECLARE SUB DLLC_Proc ALIAS "dllproc" LIB "DLLC"
  5. DECLARE SUB DLLC_Call ALIAS "dllcall" LIB "DLLC"
  6.  
  7. fih = DLLC_File("FreeImage.dll")
  8.  
  9. Version = DLLC_Proc(fih,"_FreeImage_GetVersion@0 z = ( )")
  10. Copyright = DLLC_Proc(fih,"_FreeImage_GetCopyrightMessage@0 z = ( )")
  11. LoadImage  = DLLC_Proc(fih,"_FreeImage_Load@12 i = (i fif, z filename, i flag)")
  12. Width = DLLC_Proc(fih,"_FreeImage_GetWidth@4 i = (i dib)")
  13. Height = DLLC_Proc(fih,"_FreeImage_GetHeight@4 i = (i dib)")
  14. Rescale = DLLC_Proc(fih,"_FreeImage_Rescale@16 i = (i dib, i dst_width, i dst_height, i filter)")
  15. Rotate = DLLC_Proc(fih,"_FreeImage_Rotate@16 i = (i dib, d angle, p bkcolor)")
  16. Save = DLLC_Proc(fih,"_FreeImage_Save@16 b = (i fif, i dib, z fname, i flage)")
  17.  
  18. CONST FIF_BMP  =  0
  19. CONST FIF_JPEG =  2
  20. CONST FIF_PNG  = 13
  21. CONST FIF_GIF  = 25
  22. CONST FILTER_BICUBIC = 1
  23.  
  24. PRINT DLLC_Call(Version),"\n"
  25. PRINT DLLC_Call(Copyright),"\n"
  26. fbmp = DLLC_Call(LoadImage, FIF_JPEG, "world.jpg", 0)
  27. PRINT "Width: ",DLLC_Call(Width, fbmp),"\n"
  28. PRINT "Height: ",DLLC_Call(Height, fbmp),"\n"
  29. fbmps = DLLC_Call(Rescale, fbmp, 100, 100, FILTER_BICUBIC)
  30. DLLC_Call(Save, FIF_PNG, fbmps, "world_small.png", 0)
  31. fbmpr = DLLC_Call(Rotate, fbmp, 180, 0)
  32. DLLC_Call(Save, FIF_PNG, fbmpr, "world_flip.png", 0)
  33.  

C:\SB22\test>scriba testfi.sb
3.15.4
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Width: 225
Height: 225
C:\SB22\test>

Original .jpg image


Rescaled and converted to .png


Flipped 180 degrees

« Last Edit: March 12, 2013, 10:45:09 PM by JRS »