module Graphics.LambdaCube.Image where import Data.ByteString.Lazy import Data.Word import Foreign import qualified Data.ByteString as SB import qualified Data.ByteString.Internal as SB import Graphics.LambdaCube.PixelFormat -- | Image loader function type ImageLoader = String -> ByteString -> IO (Maybe Image) -- | Has information about the size and the pixel format of the image. data Image = Image { imName :: String , imHeight :: Int , imWidth :: Int , imDepth :: Int , imNumMipmaps :: Int , imFormat :: PixelFormat , imData :: SB.ByteString -- ^ Image can be empty } imDataPtr :: Image -> Ptr Word8 imDataPtr i = plusPtr (unsafeForeignPtrToPtr fp) o where (fp,o,_l) = SB.toForeignPtr $ imData i