#ifndef _png_load_bi_
#define _png_load_bi_

#ifdef __FB_LINUX__
 #inclib "png_load_linux"
#endif
#ifdef __FB_WIN32__
 #inclib "png_load_windows"
#endif

Enum PNG_ERROR_E
  PNG_ERROR_OK                      = 0
  PNG_ERROR_DESTDEPTH               = 1
  PNG_ERROR_FILEOPEN                = 2
  PNG_ERROR_FILEREAD                = 3
  PNG_ERROR_BADSIG                  = 4
  PNG_ERROR_MEMALLOC                = 5
  PNG_ERROR_CRCFAIL                 = 6
  PNG_ERROR_BADHEADERTYPE           = 7
  PNG_ERROR_BADHEADERLEN            = 8
  PNG_ERROR_BADDIMENSIONS           = 9
  PNG_ERROR_BADBITDEPTHFORCOLORTYPE = 10
  PNG_ERROR_BADCOLORTYPE            = 11
  PNG_ERROR_BADCOMPRESSIONMETHOD    = 12
  PNG_ERROR_BADFILTERMETHOD         = 13
  PNG_ERROR_BADINTERLACEMETHOD      = 14
  PNG_ERROR_TOOFEWCHUNKS            = 15
  PNG_ERROR_BADIEND                 = 16
  PNG_ERROR_NOPALETTE               = 17
  PNG_ERROR_NOIDAT                  = 18
  PNG_ERROR_BADPALETTE              = 19
  PNG_ERROR_BADDECOMP               = 20
  PNG_ERROR_BADDECOMPSIZE           = 21
  PNG_ERROR_BADFILTERBYTE           = 22
  PNG_ERROR_UNTRAPPEDTYPE           = 23
  PNG_ERROR_BADCOLOURTYPEFORTRANS   = 24
  PNG_ERROR_BADTRANSLENGTH          = 25
End Enum

extern PNG_Error As PNG_ERROR_E

Declare Function PNG_Load(ByVal filename As ZString ptr, ByVal dest_depth As Integer = 32) As Any ptr

#if 0
' Additional code for png_load

declare function LoadPNG(byval texture as GFXType ptr, Filename as string) as integer

function LoadPNG(byval texture as GFXType ptr, Filename as string) as integer
     texture->imageData = PNG_Load(filename, 32)
     if texture->imageData = 0 then
      return false
     else
      return true
     end if
end function
#endif


declare function LoadPNG(byval texture as GFXType ptr, Filename as string) as integer

function LoadPNG(byval texture as GFXType ptr, Filename as string) as integer
 Dim img As Uinteger ptr
   img = PNG_Load(FileName,32)
   If img = NULL Then Return False

   texture->width = cptr(uShort ptr, img)[0] shr 3
   texture->height = cptr(uShort ptr, img)[1]
   texture->bpp = 32 ' ??
   texture->textype = GL_RGBA
   texture->imageData = @cptr(ubyte ptr, img)[4]
   Return True
end function

#endif
