5
votes
$ ghci
GHCi, version 7.10.1: http://www.haskell.org/ghc/  :? for help
Prelude> import Codec.Picture
Prelude Codec.Picture> Right pic &lt- readImage "smiley.bmp"
&ltinteractive>: out of memory (requested 4296015872 bytes)

smiley.bmp is under 300 bytes. Why did I run out of memory?

2
What's in the smiley.bmp file? Perhaps it claims a huge height and width? - Cirdec
@Cirdec It is only 9 by 9 pixels. You can click the link above if you want to examine it. - PyRulez
That's a really good question. I don't care so much about the actual issue, but just the completeness, hyperlinks, and all. Very impressive. Also, have you tried DevIL? - Thomas M. DuBuisson
@ThomasM.DuBuisson Putting links in the code block is actually quite difficult. I was going to raise an issue on meta about it. - PyRulez
@PyRulez Notice that DevIL can convert to Friday and Friday can convert to JuicyPixels and that can convert to Gloss, so its very nearly the same format through and through. After my patches are accepted it will all be O(1) too. - Thomas M. DuBuisson

2 Answers

5
votes

This is a bug in juicypixels where bitmaps with negative heights aren't interpreted properly.

The negative height should denote the origin is in the top left rather than bottom left corner.

I have opened a new bug report here: https://github.com/Twinside/Juicy.Pixels/issues/105

Juicy pixels does not support bitmap particularly well. There are a number of other limitations. (see https://github.com/Twinside/Juicy.Pixels/issues/96)

4
votes

This is not really a valid bitmap file and JuicyPixels is not error checking the inputs like it should. Notice the dimensions...

% file smiley.bmp
smiley.bmp: PC bitmap, Windows 3.x format, 8 x -8 x 24