úÎOÎKP      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO MContains the XYZ coordinates of a specific color in a specified color space. 2Things that can go wrong when loading a BMP file.     7Device Independent Bitmap (DIB) header for Windows V3. )(+0) Size of the image header, in bytes. $(+4) Width of the image, in pixels. %(+8) Height of the image, in pixels. (+12) Number of color planes.  (+14) Number of bits per pixel. (+16) Image compression mode. !(+20) Size of raw image data. K Some encoders set this to zero, so we need to calculate it based on the  overall file size. HIf it is non-zero then we check it matches the file size - header size. "A(+24) Prefered resolution in pixels per meter, along the X axis. #A(+28) Prefered resolution in pixels per meter, along the Y axis. $-(+32) Number of color entries that are used. %$(+36) Number of significant colors. PSize of  header (in bytes) Q7Check headers for problems and unsupported features. E With a V3 header we only support the uncompressed 24bit RGB format.  !"#$%PQ  !"#$% !"#$%PQ &BMP file header. '((+0) Magic numbers 0x42 0x4d )!(+2) Size of the file, in bytes. *(+6) Reserved, must be zero. +(+8) Reserved, must be zero. ,6(+10) Offset in bytes to the start of the pixel data. R"Size of a file header (in bytes). S:Magic number that should come at the start of a BMP file. T;Check a file header for problems and unsupported features. &'()*+,RST &'()*+,'()*+,RST-EDevice Independent Bitmap (DIB) header for Windows V4 (95 and newer) ./$Size of the image header, in bytes. 0.Color masks specify components of each pixel. 2 Only used with the bitfields compression mode. 1234#The color space used by the image. 5RSpecifies the XYZ coords of the three colors that correspond to the RGB endpoints < for the logical color space associated with the bitmap. ? Only used when ColorSpaceType specifies a calibrated image. 6+Toned response curves for each component. C Only used when the ColorSpaceType specifies a calibrated image. 78USize of .- header (in bytes) V7Check headers for problems and unsupported features. E With a V4 header we support both the uncompressed 24bit RGB format, ) and the uncompressed 32bit RGBA format. -./012345678UV- ./012345678./012345678UV 99Device Independent Bitmap (DIB) header for Windows V5 (98/2000 and newer) :;<!Rendering intent for the bitmap. =UOffset (in bytes) from the beginning of the header to the start of the profile data. >*Size (in bytes) of embedded profile data. ?Reserved, should be zero. WSize of :9 header (in bytes) X7Check headers for problems and unsupported features.  The V5 header doesn'0t give us any more useful info than the V4 one. 9:;<=>?WX 9:;<=>?:;<=>?WX@.A wrapper for the various image header types. ABCYGet the common  structure from a @ @ABCY@CBAABCY D A BMP image. U For an uncompressed image, the image data contains triples of BGR component values. T Each line may also have zero pad values on the end, to bring them up to a multiple  of 4 bytes in length. EFGHDEFGHDEFGHEFGH I9Unpack a BMP image to a string of RGBA component values. ZUUnpack raw, uncompressed 24 bit BMP image data to a string of RGBA component values. 4 The alpha component is set to 255 for every pixel. [UUnpack raw, uncompressed 32 bit BMP image data to a string of RGBA component values. N Note in the BMP file the components are arse-around ABGR instead of RGBA.  The  unpacking5 here is really just flipping the components around. II J9Pack a string of RGBA component values into a BMP image.  If the given dimensions don't match the input string then \. ` This currently ignores the alpha component of the input string and produces a 24bit RGB image. Width of image. Height of image. 5A string of RGBA component values. Must have length (width * height * 4) ]Width of image. Height of image. JJK Wrapper for L L$Get a BMP image from a file handle. F The file is checked for problems and unsupported features when read. * If there is anything wrong this gives an  instead. M Wrapper for N N"Put a BMP image to a file handle. O&Get the width and height of an image.  It'Cs better to use this function than to access the headers directly. P  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPDEFGH&'()*+,@CBA !"#$%-./0123456789:;<=>? KMLNJIOKLMNO^    !"#$$%&'()*+,-./001234566789:;<=>?@AABCDEFGHIJ K K L M N O PQRSTUVWXYZ[\]^_ ` abcd ef bmp-1.1.2.1 Codec.BMPCodec.BMP.CIEXYZCodec.BMP.ErrorCodec.BMP.BitmapInfoV3Codec.BMP.FileHeaderCodec.BMP.BitmapInfoV4Codec.BMP.BitmapInfoV5Codec.BMP.BitmapInfoCodec.BMP.BaseCodec.BMP.UnpackCodec.BMP.PackCIEXYZErrorErrorLacksWholeNumberOfLinesErrorUnexpectedImageSizeErrorUnhandledCompressionModeErrorUnhandledColorDepthErrorUnhandledPlanesCountErrorUnhandledBitmapHeaderSizeErrorFileIsTruncated!ErrorDodgyFileHeaderFieldFileSizeErrorDodgyFileHeaderFieldOffsetErrorReservedFieldNotZero ErrorBadMagicErrorReadOfImageDataFailedErrorReadOfImageHeaderFailedErrorReadOfFileHeaderFailed CompressionCompressionUnknownCompressionPNGCompressionJPEGCompressionBitFieldsCompressionRLE4CompressionRLE8CompressionRGB BitmapInfoV3dib3Size dib3Width dib3Height dib3Planes dib3BitCountdib3Compression dib3ImageSizedib3PelsPerMeterXdib3PelsPerMeterYdib3ColorsUseddib3ColorsImportant FileHeaderfileHeaderTypefileHeaderFileSizefileHeaderReserved1fileHeaderReserved2fileHeaderOffset BitmapInfoV4 dib4InfoV3 dib4RedMask dib4GreenMask dib4BlueMask dib4AlphaMaskdib4ColorSpaceType dib4Endpoints dib4GammaReddib4GammaGreen dib4GammaBlue BitmapInfoV5 dib5InfoV4 dib5Intentdib5ProfileDatadib5ProfileSize dib5Reserved BitmapInfoInfoV5InfoV4InfoV3BMP bmpFileHeader bmpBitmapInfobmpRawImageDataunpackBMPToRGBA32packRGBA32ToBMPreadBMPhGetBMPwriteBMPhPutBMP bmpDimensionssizeOfBitmapInfoV3checkBitmapInfoV3sizeOfFileHeaderbmpMagiccheckFileHeadersizeOfBitmapInfoV4checkBitmapInfoV4sizeOfBitmapInfoV5checkBitmapInfoV5getBitmapInfoV3packRGB24ToRGBA32packRGB32ToRGBA32baseGHC.ErrerrorpackRGBA32ToRGB24