gloss-1.13.1.2: Painless 2D vector graphics, animations and simulations.

Safe Haskell | None
Language | Haskell2010

Graphics.Gloss.Data.Bitmap

Description

Functions to load bitmap data from various places.

Synopsis

- data Rectangle = Rectangle {
  - rectPos :: (Int, Int)
  - rectSize :: (Int, Int)
  }
- data BitmapData
- bitmapSize :: BitmapData -> (Int, Int)
- data BitmapFormat = BitmapFormat {
  - rowOrder :: RowOrder
  - pixelFormat :: PixelFormat
  }
- data RowOrder
  - = TopToBottom
  - | BottomToTop
- data PixelFormat
  - = PxRGBA
  - | PxABGR
- bitmapOfForeignPtr :: Int -> Int -> BitmapFormat -> ForeignPtr Word8 -> Bool -> Picture
- bitmapDataOfForeignPtr :: Int -> Int -> BitmapFormat -> ForeignPtr Word8 -> Bool -> BitmapData
- bitmapOfByteString :: Int -> Int -> BitmapFormat -> ByteString -> Bool -> Picture
- bitmapDataOfByteString :: Int -> Int -> BitmapFormat -> ByteString -> Bool -> BitmapData
- bitmapOfBMP :: BMP -> Picture
- bitmapDataOfBMP :: BMP -> BitmapData
- loadBMP :: FilePath -> IO Picture

# Documentation

data Rectangle Source #

Represents a rectangular section in a bitmap

Constructors

Rectangle |

Fields

- rectPos :: (Int, Int)

  x- and y-pos in the bitmap in pixels

- rectSize :: (Int, Int)

  width/height of the area in pixelsi

#### Instances

Instances details

Eq Rectangle |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: Rectangle -> Rectangle -> Bool (/=) :: Rectangle -> Rectangle -> Bool
Data Rectangle |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Rectangle -> c Rectangle

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Rectangle

toConstr :: Rectangle -> Constr

dataTypeOf :: Rectangle -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Rectangle)

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Rectangle)

gmapT :: (forall b. Data b => b -> b) -> Rectangle -> Rectangle

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rectangle -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rectangle -> r

gmapQ :: (forall d. Data d => d -> u) -> Rectangle -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> Rectangle -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Rectangle -> m Rectangle

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Rectangle -> m Rectangle

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Rectangle -> m Rectangle

Ord Rectangle |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods compare :: Rectangle -> Rectangle -> Ordering (<) :: Rectangle -> Rectangle -> Bool (<=) :: Rectangle -> Rectangle -> Bool (>) :: Rectangle -> Rectangle -> Bool (>=) :: Rectangle -> Rectangle -> Bool max :: Rectangle -> Rectangle -> Rectangle min :: Rectangle -> Rectangle -> Rectangle
Read Rectangle |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods readsPrec :: Int -> ReadS Rectangle readList :: ReadS [Rectangle] readPrec :: ReadPrec Rectangle readListPrec :: ReadPrec [Rectangle]
Show Rectangle |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> Rectangle -> ShowS show :: Rectangle -> String showList :: [Rectangle] -> ShowS

data BitmapData Source #

Abstract 32-bit RGBA bitmap data.

#### Instances

Instances details

Eq BitmapData |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: BitmapData -> BitmapData -> Bool (/=) :: BitmapData -> BitmapData -> Bool
Data BitmapData |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BitmapData -> c BitmapData

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BitmapData

toConstr :: BitmapData -> Constr

dataTypeOf :: BitmapData -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BitmapData)

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BitmapData)

gmapT :: (forall b. Data b => b -> b) -> BitmapData -> BitmapData

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BitmapData -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BitmapData -> r

gmapQ :: (forall d. Data d => d -> u) -> BitmapData -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> BitmapData -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BitmapData -> m BitmapData

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BitmapData -> m BitmapData

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BitmapData -> m BitmapData

Show BitmapData |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> BitmapData -> ShowS show :: BitmapData -> String showList :: [BitmapData] -> ShowS

bitmapSize :: BitmapData -> (Int, Int) Source #

width, height in pixels

data BitmapFormat Source #

Description of how the bitmap is layed out in memory.

- Prior version of Gloss assumed `BitmapFormat BottomToTop PxAGBR`

Constructors

BitmapFormat |

Fields

- rowOrder :: RowOrder
- pixelFormat :: PixelFormat

#### Instances

Instances details

Eq BitmapFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: BitmapFormat -> BitmapFormat -> Bool (/=) :: BitmapFormat -> BitmapFormat -> Bool
Data BitmapFormat |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BitmapFormat -> c BitmapFormat

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BitmapFormat

toConstr :: BitmapFormat -> Constr

dataTypeOf :: BitmapFormat -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BitmapFormat)

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BitmapFormat)

gmapT :: (forall b. Data b => b -> b) -> BitmapFormat -> BitmapFormat

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BitmapFormat -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BitmapFormat -> r

gmapQ :: (forall d. Data d => d -> u) -> BitmapFormat -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> BitmapFormat -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BitmapFormat -> m BitmapFormat

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BitmapFormat -> m BitmapFormat

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BitmapFormat -> m BitmapFormat

Ord BitmapFormat |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

compare :: BitmapFormat -> BitmapFormat -> Ordering

(<) :: BitmapFormat -> BitmapFormat -> Bool

(<=) :: BitmapFormat -> BitmapFormat -> Bool

(>) :: BitmapFormat -> BitmapFormat -> Bool

(>=) :: BitmapFormat -> BitmapFormat -> Bool

max :: BitmapFormat -> BitmapFormat -> BitmapFormat

min :: BitmapFormat -> BitmapFormat -> BitmapFormat

Show BitmapFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> BitmapFormat -> ShowS show :: BitmapFormat -> String showList :: [BitmapFormat] -> ShowS

data RowOrder Source #

Order of rows in an image are either:

- `TopToBottom` - the top row, followed by the next-lower row and so on.
- `BottomToTop` - the bottom row followed by the next-higher row and so on.

Constructors

TopToBottom |
BottomToTop |

#### Instances

Instances details

Bounded RowOrder |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods minBound :: RowOrder maxBound :: RowOrder
Enum RowOrder |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods succ :: RowOrder -> RowOrder pred :: RowOrder -> RowOrder toEnum :: Int -> RowOrder fromEnum :: RowOrder -> Int enumFrom :: RowOrder -> [RowOrder] enumFromThen :: RowOrder -> RowOrder -> [RowOrder] enumFromTo :: RowOrder -> RowOrder -> [RowOrder] enumFromThenTo :: RowOrder -> RowOrder -> RowOrder -> [RowOrder]
Eq RowOrder |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: RowOrder -> RowOrder -> Bool (/=) :: RowOrder -> RowOrder -> Bool
Data RowOrder |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RowOrder -> c RowOrder

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RowOrder

toConstr :: RowOrder -> Constr

dataTypeOf :: RowOrder -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RowOrder)

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RowOrder)

gmapT :: (forall b. Data b => b -> b) -> RowOrder -> RowOrder

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RowOrder -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RowOrder -> r

gmapQ :: (forall d. Data d => d -> u) -> RowOrder -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> RowOrder -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RowOrder -> m RowOrder

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RowOrder -> m RowOrder

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RowOrder -> m RowOrder

Ord RowOrder |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods compare :: RowOrder -> RowOrder -> Ordering (<) :: RowOrder -> RowOrder -> Bool (<=) :: RowOrder -> RowOrder -> Bool (>) :: RowOrder -> RowOrder -> Bool (>=) :: RowOrder -> RowOrder -> Bool max :: RowOrder -> RowOrder -> RowOrder min :: RowOrder -> RowOrder -> RowOrder
Show RowOrder |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> RowOrder -> ShowS show :: RowOrder -> String showList :: [RowOrder] -> ShowS

data PixelFormat Source #

Pixel formats describe the order of the color channels in memory.

Constructors

PxRGBA |
PxABGR |

#### Instances

Instances details

Bounded PixelFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods minBound :: PixelFormat maxBound :: PixelFormat
Enum PixelFormat |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

succ :: PixelFormat -> PixelFormat

pred :: PixelFormat -> PixelFormat

toEnum :: Int -> PixelFormat

fromEnum :: PixelFormat -> Int

enumFrom :: PixelFormat -> [PixelFormat]

enumFromThen :: PixelFormat -> PixelFormat -> [PixelFormat]

enumFromTo :: PixelFormat -> PixelFormat -> [PixelFormat]

enumFromThenTo :: PixelFormat -> PixelFormat -> PixelFormat -> [PixelFormat]

Eq PixelFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: PixelFormat -> PixelFormat -> Bool (/=) :: PixelFormat -> PixelFormat -> Bool
Data PixelFormat |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PixelFormat -> c PixelFormat

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PixelFormat

toConstr :: PixelFormat -> Constr

dataTypeOf :: PixelFormat -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PixelFormat)

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PixelFormat)

gmapT :: (forall b. Data b => b -> b) -> PixelFormat -> PixelFormat

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PixelFormat -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PixelFormat -> r

gmapQ :: (forall d. Data d => d -> u) -> PixelFormat -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> PixelFormat -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PixelFormat -> m PixelFormat

Ord PixelFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods compare :: PixelFormat -> PixelFormat -> Ordering (<) :: PixelFormat -> PixelFormat -> Bool (<=) :: PixelFormat -> PixelFormat -> Bool (>) :: PixelFormat -> PixelFormat -> Bool (>=) :: PixelFormat -> PixelFormat -> Bool max :: PixelFormat -> PixelFormat -> PixelFormat min :: PixelFormat -> PixelFormat -> PixelFormat
Show PixelFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> PixelFormat -> ShowS show :: PixelFormat -> String showList :: [PixelFormat] -> ShowS

bitmapOfForeignPtr :: Int -> Int -> BitmapFormat -> ForeignPtr Word8 -> Bool -> Picture Source #

O(1). Use a `ForeignPtr` of RGBA data as a bitmap with the given width and height.

The boolean flag controls whether Gloss should cache the data between frames for speed. If you are programatically generating the image for each frame then use `False`. If you have loaded it from a file then use `True`.

bitmapDataOfForeignPtr :: Int -> Int -> BitmapFormat -> ForeignPtr Word8 -> Bool -> BitmapData Source #

bitmapOfByteString :: Int -> Int -> BitmapFormat -> ByteString -> Bool -> Picture Source #

O(size). Copy a `ByteString` of RGBA data into a bitmap with the given width and height.

The boolean flag controls whether Gloss should cache the data between frames for speed. If you are programatically generating the image for each frame then use `False`. If you have loaded it from a file then use `True`.

bitmapDataOfByteString :: Int -> Int -> BitmapFormat -> ByteString -> Bool -> BitmapData Source #

bitmapOfBMP :: BMP -> Picture Source #

O(size). Copy a `BMP` file into a bitmap.

bitmapDataOfBMP :: BMP -> BitmapData Source #

O(size). Copy a `BMP` file into a bitmap.

loadBMP :: FilePath -> IO Picture Source #

Load an uncompressed 24 or 32bit RGBA BMP file as a bitmap.