File: Error.hs

package info (click to toggle)
haskell-bmp 1.2.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 124 kB
  • sloc: haskell: 911; makefile: 2
file content (61 lines) | stat: -rw-r--r-- 2,011 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{-# OPTIONS_HADDOCK hide #-}
module Codec.BMP.Error
        (Error(..))
where
import Codec.BMP.Compression
import Data.Word


-- | Things that can go wrong when loading a BMP file.
data Error
        -- | Magic number was not at the start of the file, 
        --   so this probably isn't a BMP file.
        = ErrorBadMagic
        { errorMagic            :: Word16 }

        -- | File is too short to contain a file header.
        | ErrorFileHeaderTruncated

        -- | File is too short to contain an image header.
        | ErrorImageHeaderTruncated

        -- | File is too short to contain the image data.
        | ErrorImageDataTruncated
        { errorBytesNeeded      :: Int
        , errorBytesAvailable   :: Int }

        -- | Reserved fields should be zero.
        | ErrorReservedFieldNotZero

        -- | The offset to the image data from the file header doesn't
        --   point anywhere sensible.
        | ErrorDodgyFileHeaderFieldOffset
        { errorFileHeaderOffset :: Word32 }

        -- | We handle V3 V4 and V5 image headers, but the size of 
        --   the header indicates it has some other format.
        | ErrorUnhandledBitmapHeaderSize
        { errorBitmapHeaderSize :: Word32 }

        -- | We only handle single color planes.
        | ErrorUnhandledPlanesCount
        { errorPlanesCount      :: Word16 }

        -- | We only handle 24 and 32 bit images.
        | ErrorUnhandledColorDepth
        { errorColorDepth       :: Word16 }

        -- | We only handle uncompressed images.
        | ErrorUnhandledCompressionMode
        { errorCompression      :: Compression}

        -- | Mismatch between the image size stated in the header
        --   and that which is calculuated from the other fields.
        | ErrorImagePhysicalSizeMismatch 
        { errorImageSizeFromHeader  :: Word32
        , errorImageSizeOfBuffer    :: Word32 }

        -- | Something went wrong in the library.
        | ErrorInternalErrorPleaseReport
        deriving (Eq, Show)