Skip to content

Instantly share code, notes, and snippets.

@nneitzke
nneitzke / gist:1742809
Created February 5, 2012 04:45
Indentation
jpegToVectorRGBA v = do
[inname] <- ilGenImages 1
ilBindImage inname
SV.unsafeWith (SV.convert v) $ \ptr -> do
ilLoadLC il_JPG (castPtr ptr) $ fromIntegral (V.length v)
w <- ilGetIntegerC il_IMAGE_WIDTH
h <- ilGetIntegerC il_IMAGE_HEIGHT
s <- ilGetIntegerC il_IMAGE_SIZE_OF_DATA
p <- mallocArray (fromIntegral s) :: IO (Ptr Word8)
ilCopyPixelsC 0 0 0 (fromIntegral w) (fromIntegral h) 1 il_RGBA il_UNSIGNED_BYTE (castPtr p)
slice :: (Slice sh, Shape sh, Elt a) => Int -> Int -> Array (sh :. Int) a -> Array (sh :. Int) a
slice from to array =
fromFunction (z :. (to - from + 1)) (\(z :. ix) -> array ! (z :. (ix + from)))
where (z :. _) = extent array
cumsum ::
(FullShape uf ~ uf,
Slice uf,
Slice (SliceShape uf),
Shape uf,
import System.Environment
import System.IO
import Control.Applicative hiding (many)
import Data.Attoparsec as A
import qualified Data.ByteString as BS
parseMarker = do
part1 <- word8 0xFF
part2 <- notWord8 0x0