This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |