I am using JuicyPixels and want to achive the rbg data from PixelBaseComponent PixelRGB8,like bellows:
myfun1:: PixelBaseComponent PixelRGB8->IO ()
myfun1 (PixelRGB8 r g b)=do
putStrLn $ show r
But there goes wrong.
I am using JuicyPixels and want to achive the rbg data from PixelBaseComponent PixelRGB8,like bellows:
myfun1:: PixelBaseComponent PixelRGB8->IO ()
myfun1 (PixelRGB8 r g b)=do
putStrLn $ show r
But there goes wrong.
PixelBaseComponent PixelRGB8
is equal to Word8
(cf https://www.stackage.org/haddock/lts-18.4/JuicyPixels-3.3.5/src/Codec.Picture.Types.html#line-1667).
What about:
myfun1:: PixelRGB8 -> IO ()
myfun1 (PixelRGB8 r g b) = do
putStrLn $ show r
Thank you! Is there a function to convert Vector a to Ptr a or to convert ForeignPtr to Ptr?
Is there a function to convert Vector a
to Ptr a
or to convert ForeignPtr to Ptr?
There’s unsafeWith
. You might have to combine that with convert
if your vector is not storable yet.