<br>Hello,<br><br>Author of Data.Bitmap here. The issue is caused by the fact that Data.Bitmap does *not* support<br>bmp files at all. This should be clear from the documentation. The functions you tried to used use <br>their own file format, which a really very simple format; they are only added for simple experimentation. <br>
(again, this is explicit in the docs). The same documentation points to the stb-image [1] package,<br> which supports loading of some common formats (png, jpg, bmp).<br><br>In general, I suggest that with package-specific question, unless it is a widely used package,<br>
mail the maintainer directly; you have better chance to get an answer that way.<br><br>Regards,<br>Balazs<br><br>[1] <a href="http://hackage.haskell.org/package/stb-image">http://hackage.haskell.org/package/stb-image</a><br>
<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Hello,<br><br>I am using bitmap-0.2 [1] to load a Bitmap file [2]. However, the<br>following sample GHCi session fails for me.<br>
<br>&gt; Prelude Data.Bitmap Data.Bitmap.Pure.File&gt; readBitmap &quot;b.bmp&quot; :: IO (Bitmap Word8)<br>&gt; *** Exception: Data/Bitmap/Internal.hs:(63,17)-(67,15): Non-exhaustive patterns in case<br><br>I downloaded the sources of bitmap-0.2 from Hackage and modified the<br>
relevant function by appending the last line.<br><br>&gt; decodeCType :: CInt -&gt; PixelComponentType<br>&gt; decodeCType k = case k of<br>&gt;   1 -&gt; PctWord8<br>&gt;   2 -&gt; PctWord16<br>&gt;   3 -&gt; PctWord32<br>
&gt;   4 -&gt; PctFloat<br>&gt;   _ -&gt; error $ &quot;decodeCType: unexpected integer (&quot; ++ show k ++ &quot;)&quot;<br><br>With this modification the same GHCi session given above results in<br>the following error.<br>
<br>&gt; Prelude Data.Bitmap Data.Bitmap.Pure.File&gt; readBitmap &quot;b.bmp&quot; :: IO (Bitmap Word8)<br>&gt; *** Exception: decodeCType: unexpected integer (7077888)<br><br>I don&#39;t have any idea where 7077888 comes from. Am I doing something<br>
wrong? Is my bitmap corrupted in some way? The number 7077888 has no<br>apparent significance except that it is a perfect cube [3]. So I guess<br>this is not a problem with endianness.<br><br>In fact as far as I can tell `decodeCType` is only called on<br>
`(PixelComponent t =&gt; c_type t)` and `c_type t` only yields integer<br>values in the (inclusive) range of 1 to 4. That is if I am not missing<br>some orphaned instance.<br><br>Could anyone please enlighten me what is happening and if I am doing<br>
something wrong?<br><br>In case this is relevant: I am using bitmap-0.2 from Hackage with GHC<br>7.4.1 on a 3.2.20 kernel i686 architecture Linux.<br><br>Regards,<br>Alexander Foremny<br><br>[1] <a href="http://hackage.haskell.org/package/bitmap">http://hackage.haskell.org/package/bitmap</a><br>
[2] <a href="https://www.dropbox.com/s/pyutvni9vx6f6mo/b.bmp">https://www.dropbox.com/s/pyutvni9vx6f6mo/b.bmp</a><br>[3] <a href="http://www.wolframalpha.com/input/?i=7077888">http://www.wolframalpha.com/input/?i=7077888</a><br>
</blockquote><br>