rlepigre / ocaml-imagelib

The imagelib library implements image formats such as PNG or PPM
GNU Lesser General Public License v3.0
39 stars 13 forks source link

BMP: support RLE decompression (8bit/4bit) #26

Open cfcs opened 5 years ago

cfcs commented 5 years ago

The compression methods seem to be documented at least somewhat here:

I see imagemagick using these compression methods, so maybe it would make sense to implement them if someone feels like it on a rainy day. :)

@@ -249,8 +251,10 @@ module BitmapMetaData = struct
     let compression_method_of_int n =
       match n with
       | 0 -> Ok RGB
+      | 1 -> Ok RLE_8bit
+      | 2 -> Ok RLE_4bit
       | 3 -> Ok Bitfields
-      | _ -> Error (`Bmp_error "Invalid compression method")
+      | u -> Error (`Bmp_error (Printf.sprintf "Invalid compression method %#x" u))