Thanks dodicat. I didn't check the other archives for .a file. Yes, now it works.
Code: Select all
'Coded by UEZ
#Inclib "webp"
#include "file.bi"
#Include "fbgfx.bi"
Using FB
Type uint8_t As Ubyte
Type size_t As Ulong
Type tWebPBitstreamFeatures
As Long width
As Long height
As Long has_alpha
End Type
Extern "C"
Declare Function WebPGetFeatures Alias "WebPGetFeatures" (Byval data As uint8_t Ptr, Byval data_size As size_t, Byval feature As tWebPBitstreamFeatures Ptr) As Ulong
Declare Function WebPGetInfo Alias "WebPGetInfo" (Byval data As uint8_t Ptr, Byval data_size As size_t, Byval w As Long Ptr, Byval h As Long Ptr) As Ulong
Declare Function WebPDecodeRGBA Alias "WebPDecodeRGBA" (Byval data As uint8_t Ptr, Byval data_size As size_t, Byval w As Long Ptr, Byval h As Long Ptr) As ULong Ptr
Declare Function WebPDecodeARGB Alias "WebPDecodeARGB" (Byval data As uint8_t Ptr, Byval data_size As size_t, Byval w As Long Ptr, Byval h As Long Ptr) As ULong Ptr
Declare Function WebPDecodeBGRA Alias "WebPDecodeBGRA" (Byval data As uint8_t Ptr, Byval data_size As size_t, Byval w As Long Ptr, Byval h As Long Ptr) As ULong Ptr
Declare Function WebPGetDecoderVersion Alias "WebPGetDecoderVersion" () As Ulong
Declare Function WebPFree Alias "WebPFree" (Byval As ULong Ptr) As Long
End Extern
Dim As String sFile = "Picture.webp"
Dim As Uinteger iSize = Filelen(sFile)
Dim pMem As Ubyte Ptr
pMem = Allocate(iSize)
Dim As Integer hFile = Freefile()
Open sFile For Binary Access Read As #hFile
Get #hFile, 0, pMem[0], iSize
Close #hFile
Dim As Long w, h, i = 0
Dim As tWebPBitstreamFeatures WebPBitstreamFeatures
Dim As ULong Ptr pColor
? WebPGetInfo(pMem, iSize, @w, @h), w, h
? Hex(WebPGetDecoderVersion)
pColor = WebPDecodeBGRA(pMem, iSize, @w, @h)
Screenres w, h, 32, 1, GFX_ALPHA_PRIMITIVES Or GFX_NO_SWITCH
For y As Long = 0 To h - 1
For x As Long = 0 To w - 1
Pset (x, y), pColor[i]
i += 1
Next
Next
WebPFree(pColor)
Deallocate (pMem)
Sleep
The output is as expected: