png.mli 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. (*
  2. * PNG File Format Library
  3. * Copyright (c)2005 Nicolas Cannasse
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  18. *)
  19. type grey_bits =
  20. | GBits1
  21. | GBits2
  22. | GBits4
  23. | GBits8
  24. | GBits16
  25. type grey_alpha_bits =
  26. | GABits8
  27. | GABits16
  28. type true_bits =
  29. | TBits8
  30. | TBits16
  31. type index_bits =
  32. | IBits1
  33. | IBits2
  34. | IBits4
  35. | IBits8
  36. type alpha =
  37. | NoAlpha
  38. | HaveAlpha
  39. type color =
  40. | ClGreyScale of grey_bits
  41. | ClGreyAlpha of grey_alpha_bits
  42. | ClTrueColor of true_bits * alpha
  43. | ClIndexed of index_bits
  44. type header = {
  45. png_width : int;
  46. png_height : int;
  47. png_color : color;
  48. png_interlace : bool;
  49. }
  50. type chunk_id = string
  51. type chunk =
  52. | CEnd
  53. | CHeader of header
  54. | CData of string
  55. | CPalette of string
  56. | CUnknown of chunk_id * string
  57. type png = chunk list
  58. type error_msg =
  59. | Invalid_header
  60. | Invalid_file
  61. | Truncated_file
  62. | Invalid_CRC
  63. | Invalid_colors
  64. | Unsupported_colors
  65. | Invalid_datasize
  66. | Invalid_filter of int
  67. | Invalid_array
  68. exception Error of error_msg
  69. val error_msg : error_msg -> string
  70. val is_critical : chunk_id -> bool
  71. val is_public : chunk_id -> bool
  72. val is_reseverd : chunk_id -> bool
  73. val is_safe_to_copy : chunk_id -> bool
  74. val header : png -> header
  75. val data : png -> string
  76. val color_bits : color -> int
  77. val parse : IO.input -> png
  78. val write : 'a IO.output -> png -> unit
  79. val filter : png -> string -> string
  80. val make : width:int -> height:int -> pixel:(int -> int -> int32) -> compress:(string -> string) -> png