gloss-1.13.2.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

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 Source #

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

toConstr :: Rectangle -> Constr Source #

dataTypeOf :: Rectangle -> DataType Source #

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

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

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

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

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

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

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

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

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

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

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

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

compare :: Rectangle -> Rectangle -> Ordering Source #

(<) :: Rectangle -> Rectangle -> Bool Source #

(<=) :: Rectangle -> Rectangle -> Bool Source #

(>) :: Rectangle -> Rectangle -> Bool Source #

(>=) :: Rectangle -> Rectangle -> Bool Source #

max :: Rectangle -> Rectangle -> Rectangle Source #

min :: Rectangle -> Rectangle -> Rectangle Source #

data BitmapData Source #

Abstract 32-bit RGBA bitmap data.

#### Instances

Instances details

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 Source #

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

toConstr :: BitmapData -> Constr Source #

dataTypeOf :: BitmapData -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Show BitmapData |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> BitmapData -> ShowS Source # show :: BitmapData -> String Source # showList :: [BitmapData] -> ShowS Source #
Eq BitmapData |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: BitmapData -> BitmapData -> Bool Source # (/=) :: BitmapData -> BitmapData -> Bool Source #

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 PxABGR`

Constructors

BitmapFormat |

Fields

- rowOrder :: RowOrder
- pixelFormat :: PixelFormat

#### Instances

Instances details

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 Source #

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

toConstr :: BitmapFormat -> Constr Source #

dataTypeOf :: BitmapFormat -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Show BitmapFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> BitmapFormat -> ShowS Source # show :: BitmapFormat -> String Source # showList :: [BitmapFormat] -> ShowS Source #
Eq BitmapFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: BitmapFormat -> BitmapFormat -> Bool Source # (/=) :: BitmapFormat -> BitmapFormat -> Bool Source #
Ord BitmapFormat |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

compare :: BitmapFormat -> BitmapFormat -> Ordering Source #

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

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

(>) :: BitmapFormat -> BitmapFormat -> Bool Source #

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

max :: BitmapFormat -> BitmapFormat -> BitmapFormat Source #

min :: BitmapFormat -> BitmapFormat -> BitmapFormat Source #

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

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 Source #

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

toConstr :: RowOrder -> Constr Source #

dataTypeOf :: RowOrder -> DataType Source #

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

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

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

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

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

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

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

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

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

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

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

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

succ :: RowOrder -> RowOrder Source #

pred :: RowOrder -> RowOrder Source #

toEnum :: Int -> RowOrder Source #

fromEnum :: RowOrder -> Int Source #

enumFrom :: RowOrder -> [RowOrder] Source #

enumFromThen :: RowOrder -> RowOrder -> [RowOrder] Source #

enumFromTo :: RowOrder -> RowOrder -> [RowOrder] Source #

enumFromThenTo :: RowOrder -> RowOrder -> RowOrder -> [RowOrder] Source #

Show RowOrder |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> RowOrder -> ShowS Source # show :: RowOrder -> String Source # showList :: [RowOrder] -> ShowS Source #
Eq RowOrder |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: RowOrder -> RowOrder -> Bool Source # (/=) :: RowOrder -> RowOrder -> Bool Source #
Ord RowOrder |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

compare :: RowOrder -> RowOrder -> Ordering Source #

(<) :: RowOrder -> RowOrder -> Bool Source #

(<=) :: RowOrder -> RowOrder -> Bool Source #

(>) :: RowOrder -> RowOrder -> Bool Source #

(>=) :: RowOrder -> RowOrder -> Bool Source #

max :: RowOrder -> RowOrder -> RowOrder Source #

min :: RowOrder -> RowOrder -> RowOrder Source #

data PixelFormat Source #

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

Constructors

PxRGBA |
PxABGR |

#### Instances

Instances details

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 Source #

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

toConstr :: PixelFormat -> Constr Source #

dataTypeOf :: PixelFormat -> DataType Source #

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

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

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

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

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

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

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

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

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

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

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

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

succ :: PixelFormat -> PixelFormat Source #

pred :: PixelFormat -> PixelFormat Source #

toEnum :: Int -> PixelFormat Source #

fromEnum :: PixelFormat -> Int Source #

enumFrom :: PixelFormat -> [PixelFormat] Source #

enumFromThen :: PixelFormat -> PixelFormat -> [PixelFormat] Source #

enumFromTo :: PixelFormat -> PixelFormat -> [PixelFormat] Source #

enumFromThenTo :: PixelFormat -> PixelFormat -> PixelFormat -> [PixelFormat] Source #

Show PixelFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods showsPrec :: Int -> PixelFormat -> ShowS Source # show :: PixelFormat -> String Source # showList :: [PixelFormat] -> ShowS Source #
Eq PixelFormat |
Instance details Defined in Graphics.Gloss.Internals.Rendering.Bitmap Methods (==) :: PixelFormat -> PixelFormat -> Bool Source # (/=) :: PixelFormat -> PixelFormat -> Bool Source #
Ord PixelFormat |

Instance details

Defined in Graphics.Gloss.Internals.Rendering.Bitmap

Methods

compare :: PixelFormat -> PixelFormat -> Ordering Source #

(<) :: PixelFormat -> PixelFormat -> Bool Source #

(<=) :: PixelFormat -> PixelFormat -> Bool Source #

(>) :: PixelFormat -> PixelFormat -> Bool Source #

(>=) :: PixelFormat -> PixelFormat -> Bool Source #

max :: PixelFormat -> PixelFormat -> PixelFormat Source #

min :: PixelFormat -> PixelFormat -> PixelFormat Source #

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.