{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_HADDOCK hide #-}
module Graphics.Gloss.Internals.Rendering.Bitmap
( Rectangle(..)
, BitmapData(..)
, BitmapFormat(..), PixelFormat(..), RowOrder(..)
, bitmapPath
, freeBitmapData)
where
import Data.Data
import Foreign
data Rectangle
= Rectangle
{ rectPos :: (Int, Int)
, rectSize :: (Int, Int)
}
deriving (Show, Read, Eq, Ord, Data, Typeable)
data BitmapData
= BitmapData
{ bitmapDataLength :: Int
, bitmapFormat :: BitmapFormat
, bitmapSize :: (Int, Int)
, bitmapCacheMe :: Bool
, bitmapPointer :: (ForeignPtr Word8) }
deriving (Eq, Data, Typeable)
data BitmapFormat
= BitmapFormat
{ rowOrder :: RowOrder
, pixelFormat :: PixelFormat }
deriving (Eq, Data, Typeable, Show, Ord)
data RowOrder
= TopToBottom
| BottomToTop
deriving (Eq, Data, Typeable, Show, Ord, Enum, Bounded)
data PixelFormat
= PxRGBA | PxABGR
deriving (Eq, Data, Typeable, Show, Ord, Enum, Bounded)
instance Show BitmapData where
show _ = "BitmapData"
bitmapPath :: Float -> Float -> [(Float, Float)]
bitmapPath width height
= [(-width', -height'), (width', -height'), (width', height'), (-width', height')]
where width' = width / 2
height' = height / 2
freeBitmapData :: Ptr Word8 -> IO ()
freeBitmapData p = free p
{-# INLINE freeBitmapData #-}