aboutsummaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-06-07 01:35:12 +0800
committerMistivia <i@mistivia.com>2025-06-07 01:35:12 +0800
commit88845300209550777e2116b09fe21d26ae4c24aa (patch)
tree7b8b5de35e787a3ae755ac58589de1481a132914 /Main.hs
parentee5932ec51cd4a733eb0987fe45af9c7444d9581 (diff)
finish bmp writer
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs53
1 files changed, 0 insertions, 53 deletions
diff --git a/Main.hs b/Main.hs
deleted file mode 100644
index e433b09..0000000
--- a/Main.hs
+++ /dev/null
@@ -1,53 +0,0 @@
-import Data.Array.MArray
-import Data.Array.IO
-import System.IO
-import qualified Data.ByteString.Builder as B
-
-data Picture = Picture
- { picWidth :: Int
- , picHeight :: Int
- , picArray :: IOUArray Int Float}
-
-newPicture :: Int -> Int -> IO Picture
-newPicture w h = do {
- arr <- newArray (0, w * h * 3) 0.0;
- return $ Picture w h arr;
-}
-
-setPixel :: (Int, Int) -> (Float, Float, Float) -> Picture -> IO ()
-setPixel (x, y) (r, g, b) pic = let {
- idx = (y * picWidth pic + x) * 3;
-} in do {
- writeArray (picArray pic) idx r;
- writeArray (picArray pic) (idx+1) g;
- writeArray (picArray pic) (idx+2) b;
-}
-
-outputPicture :: String -> Picture -> IO ()
-outputPicture fileName pic = withBinaryFile fileName WriteMode $ \h -> let {
- fileLength = undefined;
- width = undefined;
- height = undefined;
- imageSize = undefined;
-} in do {
- B.hPutBuilder h $ mconcat
- [ -- header
- B.word16LE 0x4d42
- , B.word32LE fileLength
- , B.word32LE 0
- , B.word32LE 54
- -- info
- , B.word32LE 40
- , B.int32LE width
- , B.int32LE height
- , B.word16LE 1
- , B.word16LE 24
- , B.word32LE 0 -- BI_RGB
- , B.word32LE imageSize
- , B.word32LE 0
- , B.word32LE 0
- , B.word32LE 0
- , B.word32LE 0
- ];
-}
-