How to read a bitmap in OCAML?

后端 未结 4 1101
情歌与酒
情歌与酒 2021-01-13 00:34

I want to read a bitmap file (from the file system) using OCAML and store the pixels (the colors) inside an array which have th dimension of the bitmap, each pixel will take

4条回答
  •  日久生厌
    2021-01-13 01:13

    I don't know of an out-of-the box way to do it. You could open the file with open_in and read it byte at a time with input_char, suck in the header and the data and build up the color array array that way for simple formats (e.g. BMPs) but for anything like JPGs or PNGs a roll your-own solution would probably be more work than you want to get into.

提交回复
热议问题