free-game-1.0.1: Create games for free

Portabilitynon-portable
Stabilityexperimental
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Safe HaskellNone

FreeGame.Data.Bitmap

Contents

Description

Manipulating bitmaps

Synopsis

Basic types and functions

data Bitmap Source

Bitmap data with unique hashes.

Constructors

BitmapData (Array F DIM3 Word8) (Maybe Int)

This value is used to ensure that two bitmaps are equivalent.

Instances

_BitmapArray :: Functor f => (Array F DIM3 Word8 -> f (Array F DIM3 Word8)) -> Bitmap -> f BitmapSource

_BitmapArray :: Lens' Bitmap (Array F DIM3 Word8) The concrete data is stored as a repa array (y * x * ABGR).

bitmapSize :: Bitmap -> (Int, Int)Source

Get the size of the Bitmap.

Load and Save

readBitmap :: MonadIO m => FilePath -> m BitmapSource

Load an image file.

writeBitmap :: MonadIO m => FilePath -> Bitmap -> m ()Source

Save Bitmap into a file.

loadBitmapFromFile :: MonadIO m => FilePath -> m BitmapSource

Deprecated: use readBitmap instead

Constructing bitmaps

toBitmap :: Array F DIM3 Word8 -> BitmapSource

Create unstable Bitmap from the given array.

toStableBitmap :: Array F DIM3 Word8 -> BitmapSource

Create stable Bitmap from the given array and compute the hash.

makeStableBitmap :: Array F DIM3 Word8 -> IO BitmapSource

Create stable Bitmap with unique hash from the given array.

Bitmap operations

onBitmapWithHashable :: Hashable h => h -> (Array F DIM3 Word8 -> Array F DIM3 Word8) -> Bitmap -> BitmapSource

Convert the Bitmap uniformalized by the Hashable value by the given function.

cropBitmapSource

Arguments

:: Bitmap

original bitmap

-> (Int, Int)

width and height

-> (Int, Int)

x and y

-> Bitmap

result

Extract a Bitmap from the specified range.