This file is indexed.

/usr/share/doc/libghc-juicypixels-doc/html/JuicyPixels.txt is in libghc-juicypixels-doc 3.2.9.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance)
--   
--   
--   This library can load and store images in PNG,Bitmap, Jpeg, Radiance,
--   Tiff and Gif images.
@package JuicyPixels
@version 3.2.9.1


-- | Module provides basic types for image manipulation in the library.
--   Defined types are used to store all of those <b>Juicy Pixels</b>
module Codec.Picture.Types

-- | The main type of this package, one that most functions work on, is
--   Image.
--   
--   Parameterized by the underlying pixel format it forms a rigid type. If
--   you wish to store images of different or unknown pixel formats use
--   <a>DynamicImage</a>.
--   
--   Image is essentially a rectangular pixel buffer of specified width and
--   height. The coordinates are assumed to start from the upper-left
--   corner of the image, with the horizontal position first and vertical
--   second.
data Image a
Image :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Vector (PixelBaseComponent a) -> Image a

-- | Width of the image in pixels
[imageWidth] :: Image a -> {-# UNPACK #-} !Int

-- | Height of the image in pixels.
[imageHeight] :: Image a -> {-# UNPACK #-} !Int

-- | Image pixel data. To extract pixels at a given position you should use
--   the helper functions.
--   
--   Internally pixel data is stored as consecutively packed lines from top
--   to bottom, scanned from left to right within individual lines, from
--   first to last color component within each pixel.
[imageData] :: Image a -> Vector (PixelBaseComponent a)

-- | Image or pixel buffer, the coordinates are assumed to start from the
--   upper-left corner of the image, with the horizontal position first,
--   then the vertical one. The image can be transformed in place.
data MutableImage s a
MutableImage :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> STVector s (PixelBaseComponent a) -> MutableImage s a

-- | Width of the image in pixels
[mutableImageWidth] :: MutableImage s a -> {-# UNPACK #-} !Int

-- | Height of the image in pixels.
[mutableImageHeight] :: MutableImage s a -> {-# UNPACK #-} !Int

-- | The real image, to extract pixels at some position you should use the
--   helpers functions.
[mutableImageData] :: MutableImage s a -> STVector s (PixelBaseComponent a)

-- | Image type enumerating all predefined pixel types. It enables loading
--   and use of images of different pixel types.
data DynamicImage

-- | A greyscale image.
ImageY8 :: (Image Pixel8) -> DynamicImage

-- | A greyscale image with 16bit components
ImageY16 :: (Image Pixel16) -> DynamicImage

-- | A greyscale HDR image
ImageYF :: (Image PixelF) -> DynamicImage

-- | An image in greyscale with an alpha channel.
ImageYA8 :: (Image PixelYA8) -> DynamicImage

-- | An image in greyscale with alpha channel on 16 bits.
ImageYA16 :: (Image PixelYA16) -> DynamicImage

-- | An image in true color.
ImageRGB8 :: (Image PixelRGB8) -> DynamicImage

-- | An image in true color with 16bit depth.
ImageRGB16 :: (Image PixelRGB16) -> DynamicImage

-- | An image with HDR pixels
ImageRGBF :: (Image PixelRGBF) -> DynamicImage

-- | An image in true color and an alpha channel.
ImageRGBA8 :: (Image PixelRGBA8) -> DynamicImage

-- | A true color image with alpha on 16 bits.
ImageRGBA16 :: (Image PixelRGBA16) -> DynamicImage

-- | An image in the colorspace used by Jpeg images.
ImageYCbCr8 :: (Image PixelYCbCr8) -> DynamicImage

-- | An image in the colorspace CMYK
ImageCMYK8 :: (Image PixelCMYK8) -> DynamicImage

-- | An image in the colorspace CMYK and 16 bits precision
ImageCMYK16 :: (Image PixelCMYK16) -> DynamicImage

-- | Describe an image and it's potential associated palette. If no palette
--   is present, fallback to a DynamicImage
data PalettedImage

-- | Fallback
TrueColorImage :: DynamicImage -> PalettedImage
PalettedY8 :: (Image Pixel8) -> (Palette' Pixel8) -> PalettedImage
PalettedRGB8 :: (Image Pixel8) -> (Palette' PixelRGB8) -> PalettedImage
PalettedRGBA8 :: (Image Pixel8) -> (Palette' PixelRGBA8) -> PalettedImage
PalettedRGB16 :: (Image Pixel8) -> (Palette' PixelRGB16) -> PalettedImage

-- | Type for the palette used in Gif &amp; PNG files.
type Palette = Image PixelRGB8

-- | Type used to expose a palette extracted during reading. Use
--   palettedAsImage to convert it to a palette usable for writing.
data Palette' px
Palette' :: !Int -> !(Vector (PixelBaseComponent px)) -> Palette' px

-- | Number of element in pixels.
[_paletteSize] :: Palette' px -> !Int

-- | Real data used by the palette.
[_paletteData] :: Palette' px -> !(Vector (PixelBaseComponent px))

-- | Create a mutable image, filled with the given background color.
createMutableImage :: (Pixel px, PrimMonad m) => Int -> Int -> px -> m (MutableImage (PrimState m) px)

-- | Create a mutable image with garbage as content. All data is
--   uninitialized.
newMutableImage :: forall px m. (Pixel px, PrimMonad m) => Int -> Int -> m (MutableImage (PrimState m) px)

-- | `O(n)` Yield an immutable copy of an image by making a copy of it
freezeImage :: (Storable (PixelBaseComponent px), PrimMonad m) => MutableImage (PrimState m) px -> m (Image px)

-- | `O(1)` Unsafe convert a mutable image to an immutable one without
--   copying. The mutable image may not be used after this operation.
unsafeFreezeImage :: (Storable (PixelBaseComponent a), PrimMonad m) => MutableImage (PrimState m) a -> m (Image a)

-- | `O(n)` Yield a mutable copy of an image by making a copy of it.
thawImage :: (Storable (PixelBaseComponent px), PrimMonad m) => Image px -> m (MutableImage (PrimState m) px)

-- | `O(1)` Unsafe convert an imutable image to an mutable one without
--   copying. The source image shouldn't be used after this operation.
unsafeThawImage :: (Storable (PixelBaseComponent px), PrimMonad m) => Image px -> m (MutableImage (PrimState m) px)

-- | Traversal type matching the definition in the Lens package.
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t

-- | Traversal in "raster" order, from left to right the top to bottom.
--   This traversal is matching pixelMap in spirit.
--   
--   Since 3.2.4
imagePixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) pxa pxb

-- | Traversal providing the pixel position with it's value. The traversal
--   in raster order, from lef to right, then top to bottom. The traversal
--   match pixelMapXY in spirit.
--   
--   Since 3.2.4
imageIPixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) (Int, Int, pxa) pxb

-- | Type alias for 8bit greyscale pixels. For simplicity, greyscale pixels
--   use plain numbers instead of a separate type.
type Pixel8 = Word8

-- | Type alias for 16bit greyscale pixels.
type Pixel16 = Word16

-- | Type alias for 32bit greyscale pixels.
type Pixel32 = Word32

-- | Type alias for 32bit floating point greyscale pixels. The standard
--   bounded value range is mapped to the closed interval [0,1] i.e.
--   
--   <pre>
--   map promotePixel [0, 1 .. 255 :: Pixel8] == [0/255, 1/255 .. 1.0 :: PixelF]
--   </pre>
type PixelF = Float

-- | Pixel type storing 8bit Luminance (Y) and alpha (A) information.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Luminance</li>
--   <li>Alpha</li>
--   </ul>
data PixelYA8
PixelYA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYA8

-- | Pixel type storing 16bit Luminance (Y) and alpha (A) information.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Luminance</li>
--   <li>Alpha</li>
--   </ul>
data PixelYA16
PixelYA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelYA16

-- | Classic pixel type storing 8bit red, green and blue (RGB) information.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   </ul>
data PixelRGB8
PixelRGB8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGB8

-- | Pixel type storing 16bit red, green and blue (RGB) information. Values
--   are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   </ul>
data PixelRGB16
PixelRGB16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGB16

-- | HDR pixel type storing floating point 32bit red, green and blue (RGB)
--   information. Same value range and comments apply as for <a>PixelF</a>.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   </ul>
data PixelRGBF
PixelRGBF :: {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> PixelRGBF

-- | Classical pixel type storing 8bit red, green, blue and alpha (RGBA)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   <li>Alpha</li>
--   </ul>
data PixelRGBA8
PixelRGBA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGBA8

-- | Pixel type storing 16bit red, green, blue and alpha (RGBA)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   <li>Alpha</li>
--   </ul>
data PixelRGBA16
PixelRGBA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGBA16

-- | Pixel type storing 8bit cyan, magenta, yellow and black (CMYK)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Cyan</li>
--   <li>Magenta</li>
--   <li>Yellow</li>
--   <li>Black</li>
--   </ul>
data PixelCMYK8
PixelCMYK8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelCMYK8

-- | Pixel type storing 16bit cyan, magenta, yellow and black (CMYK)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Cyan</li>
--   <li>Magenta</li>
--   <li>Yellow</li>
--   <li>Black</li>
--   </ul>
data PixelCMYK16
PixelCMYK16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelCMYK16

-- | Pixel type storing 8bit luminance, blue difference and red difference
--   (YCbCr) information. Values are stored in the following order:
--   
--   <ul>
--   <li>Y (luminance)</li>
--   <li>Cb</li>
--   <li>Cr</li>
--   </ul>
data PixelYCbCr8
PixelYCbCr8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYCbCr8

-- | Pixel type storing value for the YCCK color space:
--   
--   <ul>
--   <li>Y (Luminance)</li>
--   <li>Cb</li>
--   <li>Cr</li>
--   <li>Black</li>
--   </ul>
data PixelYCbCrK8
PixelYCbCrK8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYCbCrK8

-- | Implement upcasting for pixel types. Minimal declaration of
--   <a>promotePixel</a>. It is strongly recommended to overload
--   promoteImage to keep performance acceptable
class (Pixel a, Pixel b) => ColorConvertible a b where promoteImage = pixelMap promotePixel

-- | Convert a pixel type to another pixel type. This operation should
--   never lose any data.
promotePixel :: ColorConvertible a b => a -> b

-- | Change the underlying pixel type of an image by performing a full copy
--   of it.
promoteImage :: ColorConvertible a b => Image a -> Image b

-- | Definition of pixels used in images. Each pixel has a color space, and
--   a representative component (Word8 or Float).
class (Storable (PixelBaseComponent a), Num (PixelBaseComponent a), Eq a) => Pixel a where type PixelBaseComponent a :: * mixWithAlpha f _ = mixWith f pixelBaseIndex (Image {imageWidth = w}) x y = (x + y * w) * componentCount (undefined :: a) mutablePixelBaseIndex (MutableImage {mutableImageWidth = w}) x y = (x + y * w) * componentCount (undefined :: a) where {
    type family PixelBaseComponent a :: *;
}

-- | Call the function for every component of the pixels. For example for
--   RGB pixels mixWith is declared like this:
--   
--   <pre>
--   mixWith f (PixelRGB8 ra ga ba) (PixelRGB8 rb gb bb) =
--      PixelRGB8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb)
--   </pre>
mixWith :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a

-- | Extension of the <a>mixWith</a> which separate the treatment of the
--   color components of the alpha value (transparency component). For
--   pixel without alpha components, it is equivalent to mixWith.
--   
--   <pre>
--   mixWithAlpha f fa (PixelRGBA8 ra ga ba aa) (PixelRGB8 rb gb bb ab) =
--      PixelRGBA8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) (fa aa ab)
--   </pre>
mixWithAlpha :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> (PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a

-- | Return the opacity of a pixel, if the pixel has an alpha layer, return
--   the alpha value. If the pixel doesn't have an alpha value, return a
--   value representing the opaqueness.
pixelOpacity :: Pixel a => a -> PixelBaseComponent a

-- | Return the number of components of the pixel
componentCount :: Pixel a => a -> Int

-- | Apply a function to each component of a pixel. If the color type
--   possess an alpha (transparency channel), it is treated like the other
--   color components.
colorMap :: Pixel a => (PixelBaseComponent a -> PixelBaseComponent a) -> a -> a

-- | Calculate the index for the begining of the pixel
pixelBaseIndex :: Pixel a => Image a -> Int -> Int -> Int

-- | Calculate theindex for the begining of the pixel at position x y
mutablePixelBaseIndex :: Pixel a => MutableImage s a -> Int -> Int -> Int

-- | Extract a pixel at a given position, (x, y), the origin is assumed to
--   be at the corner top left, positive y to the bottom of the image
pixelAt :: Pixel a => Image a -> Int -> Int -> a

-- | Same as pixelAt but for mutable images.
readPixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> m a

-- | Write a pixel in a mutable image at position x y
writePixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> a -> m ()

-- | Unsafe version of pixelAt, read a pixel at the given index without
--   bound checking (if possible). The index is expressed in number
--   (PixelBaseComponent a)
unsafePixelAt :: Pixel a => Vector (PixelBaseComponent a) -> Int -> a

-- | Unsafe version of readPixel, read a pixel at the given position
--   without bound checking (if possible). The index is expressed in number
--   (PixelBaseComponent a)
unsafeReadPixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> m a

-- | Unsafe version of writePixel, write a pixel at the given position
--   without bound checking. This can be _really_ unsafe. The index is
--   expressed in number (PixelBaseComponent a)
unsafeWritePixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> a -> m ()

-- | This class abstract colorspace conversion. This conversion can be
--   lossy, which ColorConvertible cannot
class (Pixel a, Pixel b) => ColorSpaceConvertible a b where convertImage = pixelMap convertPixel

-- | Pass a pixel from a colorspace (say RGB) to the second one (say YCbCr)
convertPixel :: ColorSpaceConvertible a b => a -> b

-- | Helper function to convert a whole image by taking a copy it.
convertImage :: ColorSpaceConvertible a b => Image a -> Image b

-- | Helper class to help extract a luma plane out of an image or a pixel
class (Pixel a, Pixel (PixelBaseComponent a)) => LumaPlaneExtractable a where extractLumaPlane = pixelMap computeLuma

-- | Compute the luminance part of a pixel
computeLuma :: LumaPlaneExtractable a => a -> PixelBaseComponent a

-- | Extract a luma plane out of an image. This method is in the typeclass
--   to help performant implementation.
--   
--   <pre>
--   jpegToGrayScale :: FilePath -&gt; FilePath -&gt; IO ()
--   jpegToGrayScale source dest
--   </pre>
extractLumaPlane :: LumaPlaneExtractable a => Image a -> Image (PixelBaseComponent a)

-- | Class modeling transparent pixel, should provide a method to combine
--   transparent pixels
class (Pixel a, Pixel b) => TransparentPixel a b | a -> b

-- | Just return the opaque pixel value
dropTransparency :: TransparentPixel a b => a -> b

-- | access the transparency (alpha layer) of a given transparent pixel
--   type.

-- | <i>Deprecated: please use <a>pixelOpacity</a> instead</i>
getTransparency :: TransparentPixel a b => a -> PixelBaseComponent a

-- | <a>map</a> equivalent for an image, working at the pixel level. Little
--   example : a brightness function for an rgb image
--   
--   <pre>
--   brightnessRGB8 :: Int -&gt; Image PixelRGB8 -&gt; Image PixelRGB8
--   brightnessRGB8 add = pixelMap brightFunction
--        where up v = fromIntegral (fromIntegral v + add)
--              brightFunction (PixelRGB8 r g b) =
--                      PixelRGB8 (up r) (up g) (up b)
--   </pre>
pixelMap :: forall a b. (Pixel a, Pixel b) => (a -> b) -> Image a -> Image b

-- | Just like <a>pixelMap</a> only the function takes the pixel
--   coordinates as additional parameters.
pixelMapXY :: forall a b. (Pixel a, Pixel b) => (Int -> Int -> a -> b) -> Image a -> Image b

-- | Fold over the pixel of an image with a raster scan order: from top to
--   bottom, left to right
pixelFold :: forall acc pixel. (Pixel pixel) => (acc -> Int -> Int -> pixel -> acc) -> acc -> Image pixel -> acc

-- | Fold over the pixel of an image with a raster scan order: from top to
--   bottom, left to right, carrying out a state
pixelFoldM :: (Pixel pixel, Monad m) => (acc -> Int -> Int -> pixel -> m acc) -> acc -> Image pixel -> m acc

-- | Fold over the pixel of an image with a raster scan order: from top to
--   bottom, left to right. This functions is analog to the foldMap from
--   the <a>Foldable</a> typeclass, but due to the Pixel constraint, Image
--   cannot be made an instance of it.
pixelFoldMap :: forall m px. (Pixel px, Monoid m) => (px -> m) -> Image px -> m

-- | Helper function to help extract information from dynamic image. To get
--   the width of a dynamic image, you can use the following snippet:
--   
--   <pre>
--   dynWidth :: DynamicImage -&gt; Int
--   dynWidth img = dynamicMap imageWidth img
--   </pre>
dynamicMap :: (forall pixel. (Pixel pixel) => Image pixel -> a) -> DynamicImage -> a

-- | Equivalent of the <a>pixelMap</a> function for the dynamic images. You
--   can perform pixel colorspace independant operations with this
--   function.
--   
--   For instance, if you want to extract a square crop of any image,
--   without caring about colorspace, you can use the following snippet.
--   
--   <pre>
--   dynSquare :: DynamicImage -&gt; DynamicImage
--   dynSquare = dynamicPixelMap squareImage
--   
--   squareImage :: Pixel a =&gt; Image a -&gt; Image a
--   squareImage img = generateImage (\x y -&gt; pixelAt img x y) edge edge
--      where edge = min (imageWidth img) (imageHeight img)
--   </pre>
dynamicPixelMap :: (forall pixel. (Pixel pixel) => Image pixel -> Image pixel) -> DynamicImage -> DynamicImage

-- | Flatten a PalettedImage to a DynamicImage
palettedToTrueColor :: PalettedImage -> DynamicImage

-- | Convert a palette to an image. Used mainly for backward compatibility.
palettedAsImage :: Palette' px -> Image px

-- | For any image with an alpha component (transparency), drop it,
--   returning a pure opaque image.
dropAlphaLayer :: (TransparentPixel a b) => Image a -> Image b

-- | Create an image using a monadic initializer function. The function
--   will receive values from 0 to width-1 for the x parameter and 0 to
--   height-1 for the y parameter. The coordinates 0,0 are the upper left
--   corner of the image, and (width-1, height-1) the lower right corner.
--   
--   The function is called for each pixel in the line from left to right
--   (0 to width - 1) and for each line (0 to height - 1).
withImage :: forall m pixel. (Pixel pixel, PrimMonad m) => Int -> Int -> (Int -> Int -> m pixel) -> m (Image pixel)

-- | Combine, pixel by pixel and component by component the values of 3
--   different images. Usage example:
--   
--   <pre>
--   averageBrightNess c1 c2 c3 = clamp $ toInt c1 + toInt c2 + toInt c3
--     where clamp = fromIntegral . min 0 . max 255
--           toInt :: a -&gt; Int
--           toInt = fromIntegral
--   ziPixelComponent3 averageBrightNess img1 img2 img3
--   </pre>
zipPixelComponent3 :: forall px. (Storable (PixelBaseComponent px)) => (PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px) -> Image px -> Image px -> Image px -> Image px

-- | Create an image given a function to generate pixels. The function will
--   receive values from 0 to width-1 for the x parameter and 0 to height-1
--   for the y parameter. The coordinates 0,0 are the upper left corner of
--   the image, and (width-1, height-1) the lower right corner.
--   
--   for example, to create a small gradient image:
--   
--   <pre>
--   imageCreator :: String -&gt; IO ()
--   imageCreator path = writePng path $ generateImage pixelRenderer 250 300
--      where pixelRenderer x y = PixelRGB8 (fromIntegral x) (fromIntegral y) 128
--   </pre>
generateImage :: forall px. (Pixel px) => (Int -> Int -> px) -> Int -> Int -> Image px

-- | Create an image given a function to generate pixels. The function will
--   receive values from 0 to width-1 for the x parameter and 0 to height-1
--   for the y parameter. The coordinates 0,0 are the upper left corner of
--   the image, and (width-1, height-1) the lower right corner.
--   
--   the acc parameter is a user defined one.
--   
--   The function is called for each pixel in the line from left to right
--   (0 to width - 1) and for each line (0 to height - 1).
generateFoldImage :: forall a acc. (Pixel a) => (acc -> Int -> Int -> (acc, a)) -> acc -> Int -> Int -> (acc, Image a)

-- | Perform a gamma correction for an image with HDR pixels.
gammaCorrection :: PixelF -> Image PixelRGBF -> Image PixelRGBF

-- | Perform a tone mapping operation on an High dynamic range image.
toneMapping :: PixelF -> Image PixelRGBF -> Image PixelRGBF

-- | Class used to describle plane present in the pixel type. If a pixel
--   has a plane description associated, you can use the plane name to
--   extract planes independently.
class ColorPlane pixel planeToken

-- | Define the plane for the red color component
data PlaneRed
PlaneRed :: PlaneRed

-- | Define the plane for the green color component
data PlaneGreen
PlaneGreen :: PlaneGreen

-- | Define the plane for the blue color component
data PlaneBlue
PlaneBlue :: PlaneBlue

-- | Define the plane for the alpha (transparency) component
data PlaneAlpha
PlaneAlpha :: PlaneAlpha

-- | Define the plane for the luma component
data PlaneLuma
PlaneLuma :: PlaneLuma

-- | Define the plane for the Cr component
data PlaneCr
PlaneCr :: PlaneCr

-- | Define the plane for the Cb component
data PlaneCb
PlaneCb :: PlaneCb

-- | Define plane for the cyan component of the CMYK color space.
data PlaneCyan
PlaneCyan :: PlaneCyan

-- | Define plane for the magenta component of the CMYK color space.
data PlaneMagenta
PlaneMagenta :: PlaneMagenta

-- | Define plane for the yellow component of the CMYK color space.
data PlaneYellow
PlaneYellow :: PlaneYellow

-- | Define plane for the black component of the CMYK color space.
data PlaneBlack
PlaneBlack :: PlaneBlack

-- | Extract a color plane from an image given a present plane in the image
--   examples:
--   
--   <pre>
--   extractRedPlane :: Image PixelRGB8 -&gt; Image Pixel8
--   extractRedPlane = extractComponent PlaneRed
--   </pre>
extractComponent :: forall px plane. (Pixel px, Pixel (PixelBaseComponent px), PixelBaseComponent (PixelBaseComponent px) ~ PixelBaseComponent px, ColorPlane px plane) => plane -> Image px -> Image (PixelBaseComponent px)

-- | Extract a plane of an image. Returns the requested color component as
--   a greyscale image.
--   
--   If you ask for a component out of bound, the <a>error</a> function
--   will be called.
unsafeExtractComponent :: forall a. (Pixel a, Pixel (PixelBaseComponent a), PixelBaseComponent (PixelBaseComponent a) ~ PixelBaseComponent a) => Int -> Image a -> Image (PixelBaseComponent a)

-- | This typeclass exist for performance reason, it allow to pack a pixel
--   value to a simpler "primitive" data type to allow faster writing to
--   moemory.
class PackeablePixel a where type PackedRepresentation a where {
    type family PackedRepresentation a;
}

-- | The packing function, allowing to transform to a primitive.
packPixel :: PackeablePixel a => a -> PackedRepresentation a

-- | Inverse transformation, to speed up reading
unpackPixel :: PackeablePixel a => PackedRepresentation a -> a

-- | This function will fill an image with a simple packeable pixel. It
--   will be faster than any unsafeWritePixel.
fillImageWith :: (Pixel px, PackeablePixel px, PrimMonad m, Storable (PackedRepresentation px)) => MutableImage (PrimState m) px -> px -> m ()

-- | Read a packeable pixel from an image. Equivalent to unsafeReadPixel
readPackedPixelAt :: forall m px. (Pixel px, PackeablePixel px, Storable (PackedRepresentation px), PrimMonad m) => MutableImage (PrimState m) px -> Int -> m px

-- | Write a packeable pixel into an image. equivalent to unsafeWritePixel.
writePackedPixelAt :: (Pixel px, PackeablePixel px, Storable (PackedRepresentation px), PrimMonad m) => MutableImage (PrimState m) px -> Int -> px -> m ()

-- | Fill a packeable pixel between two bounds.
unsafeWritePixelBetweenAt :: (PrimMonad m, Pixel px, PackeablePixel px, Storable (PackedRepresentation px)) => MutableImage (PrimState m) px -> px -> Int -> Int -> m ()
instance GHC.Show.Show Codec.Picture.Types.PixelRGBA16
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBA16
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBA16
instance GHC.Show.Show Codec.Picture.Types.PixelRGBA8
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBA8
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBA8
instance GHC.Show.Show Codec.Picture.Types.PixelCMYK16
instance GHC.Classes.Ord Codec.Picture.Types.PixelCMYK16
instance GHC.Classes.Eq Codec.Picture.Types.PixelCMYK16
instance GHC.Show.Show Codec.Picture.Types.PixelCMYK8
instance GHC.Classes.Ord Codec.Picture.Types.PixelCMYK8
instance GHC.Classes.Eq Codec.Picture.Types.PixelCMYK8
instance GHC.Show.Show Codec.Picture.Types.PixelYCbCr8
instance GHC.Classes.Ord Codec.Picture.Types.PixelYCbCr8
instance GHC.Classes.Eq Codec.Picture.Types.PixelYCbCr8
instance GHC.Show.Show Codec.Picture.Types.PixelRGBF
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBF
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBF
instance GHC.Show.Show Codec.Picture.Types.PixelRGB16
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGB16
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGB16
instance GHC.Show.Show Codec.Picture.Types.PixelYCbCrK8
instance GHC.Classes.Ord Codec.Picture.Types.PixelYCbCrK8
instance GHC.Classes.Eq Codec.Picture.Types.PixelYCbCrK8
instance GHC.Show.Show Codec.Picture.Types.PixelRGB8
instance GHC.Classes.Ord Codec.Picture.Types.PixelRGB8
instance GHC.Classes.Eq Codec.Picture.Types.PixelRGB8
instance GHC.Show.Show Codec.Picture.Types.PixelYA16
instance GHC.Classes.Ord Codec.Picture.Types.PixelYA16
instance GHC.Classes.Eq Codec.Picture.Types.PixelYA16
instance GHC.Show.Show Codec.Picture.Types.PixelYA8
instance GHC.Classes.Ord Codec.Picture.Types.PixelYA8
instance GHC.Classes.Eq Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PixelRGB8
instance Control.DeepSeq.NFData (Codec.Picture.Types.Image a)
instance Control.DeepSeq.NFData (Codec.Picture.Types.MutableImage s a)
instance Control.DeepSeq.NFData Codec.Picture.Types.DynamicImage
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel32
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelF
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Types.Pixel a => Codec.Picture.Types.ColorConvertible a a
instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelF
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelYA16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel32
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelF
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelF Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PlaneLuma
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PlaneAlpha
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelYA8 Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelYA8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYA16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PlaneLuma
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PlaneAlpha
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelYA16 Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBF
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneAlpha
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneRed
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneGreen
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneBlue
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneAlpha
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Types.Pixel a => Codec.Picture.Types.ColorSpaceConvertible a a
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneLuma
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneCb
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneCr
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYCbCrK8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCrK8 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCrK8 Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneCyan
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneMagenta
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneYellow
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneBlack
instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneCyan
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneMagenta
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneYellow
instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneBlack
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel8
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel32
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelF
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelYA16
instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelYA8


-- | This module provide a totally partial and incomplete maping of Exif
--   values. Used for Tiff parsing and reused for Exif extraction.
module Codec.Picture.Metadata.Exif

-- | Tag values used for exif fields. Completly incomplete
data ExifTag
TagPhotometricInterpretation :: ExifTag

-- | Short type
TagCompression :: ExifTag

-- | Short or long type
TagImageWidth :: ExifTag

-- | Short or long type
TagImageLength :: ExifTag

-- | Rational type
TagXResolution :: ExifTag

-- | Rational type
TagYResolution :: ExifTag
TagResolutionUnit :: ExifTag

-- | Short or long type
TagRowPerStrip :: ExifTag

-- | Short or long
TagStripByteCounts :: ExifTag

-- | Short or long
TagStripOffsets :: ExifTag
TagBitsPerSample :: ExifTag

-- | Short
TagColorMap :: ExifTag
TagTileWidth :: ExifTag
TagTileLength :: ExifTag
TagTileOffset :: ExifTag
TagTileByteCount :: ExifTag

-- | Short
TagSamplesPerPixel :: ExifTag
TagArtist :: ExifTag
TagDocumentName :: ExifTag
TagSoftware :: ExifTag

-- | Short
TagPlanarConfiguration :: ExifTag
TagOrientation :: ExifTag

-- | Short
TagSampleFormat :: ExifTag
TagInkSet :: ExifTag
TagSubfileType :: ExifTag
TagFillOrder :: ExifTag
TagYCbCrCoeff :: ExifTag
TagYCbCrSubsampling :: ExifTag
TagYCbCrPositioning :: ExifTag
TagReferenceBlackWhite :: ExifTag
TagXPosition :: ExifTag
TagYPosition :: ExifTag
TagExtraSample :: ExifTag
TagImageDescription :: ExifTag
TagPredictor :: ExifTag
TagCopyright :: ExifTag
TagMake :: ExifTag
TagModel :: ExifTag
TagDateTime :: ExifTag
TagGPSInfo :: ExifTag

-- | Short
TagLightSource :: ExifTag

-- | Short
TagFlash :: ExifTag
TagJpegProc :: ExifTag
TagJPEGInterchangeFormat :: ExifTag
TagJPEGInterchangeFormatLength :: ExifTag
TagJPEGRestartInterval :: ExifTag
TagJPEGLosslessPredictors :: ExifTag
TagJPEGPointTransforms :: ExifTag
TagJPEGQTables :: ExifTag
TagJPEGDCTables :: ExifTag
TagJPEGACTables :: ExifTag
TagExifOffset :: ExifTag
TagUnknown :: !Word16 -> ExifTag

-- | Possible data held by an Exif tag
data ExifData
ExifNone :: ExifData
ExifLong :: !Word32 -> ExifData
ExifShort :: !Word16 -> ExifData
ExifString :: !ByteString -> ExifData
ExifUndefined :: !ByteString -> ExifData
ExifShorts :: !(Vector Word16) -> ExifData
ExifLongs :: !(Vector Word32) -> ExifData
ExifRational :: !Word32 -> !Word32 -> ExifData
ExifSignedRational :: !Int32 -> !Int32 -> ExifData
ExifIFD :: ![(ExifTag, ExifData)] -> ExifData

-- | Convert a value to it's corresponding Exif tag. Will often be written
--   as <a>TagUnknown</a>
tagOfWord16 :: Word16 -> ExifTag

-- | Convert a tag to it's corresponding value.
word16OfTag :: ExifTag -> Word16
isInIFD0 :: ExifTag -> Bool
instance GHC.Show.Show Codec.Picture.Metadata.Exif.ExifData
instance GHC.Show.Show Codec.Picture.Metadata.Exif.ExifTag
instance GHC.Classes.Ord Codec.Picture.Metadata.Exif.ExifTag
instance GHC.Classes.Eq Codec.Picture.Metadata.Exif.ExifTag
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Exif.ExifTag
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Exif.ExifData


-- | This module expose a common "metadata" storage for various image type.
--   Different format can generate different metadatas, and write only a
--   part of them.
--   
--   Since version 3.2.5
module Codec.Picture.Metadata

-- | Dependent storage used for metadatas. All metadatas of a given kind
--   are unique within this container.
--   
--   The current data structure is based on list, so bad performances can
--   be expected.
data Metadatas

-- | Store various additional information about an image. If something is
--   not recognized, it can be stored in an unknown tag.
--   
--   <ul>
--   <li><a>DpiX</a> Dot per inch on this x axis.</li>
--   <li><a>DpiY</a> Dot per inch on this y axis.</li>
--   <li><a>Width</a> Image width in pixel. Relying on the metadata for
--   this information can avoid the full decompression of the image.
--   Ignored for image writing.</li>
--   <li><a>Height</a> Image height in pixels. Relyiung on the metadata for
--   this information can void the full decomrpession of the image. Ignored
--   for image writing.</li>
--   <li><a>Unknown</a> unlikely to be decoded, but usefull for metadata
--   writing</li>
--   <li><a>Exif</a> Exif tag and associated data.</li>
--   </ul>
data Keys a
[Gamma] :: Keys Double
[Format] :: Keys SourceFormat
[DpiX] :: Keys Word
[DpiY] :: Keys Word
[Width] :: Keys Word
[Height] :: Keys Word
[Title] :: Keys String
[Description] :: Keys String
[Author] :: Keys String
[Copyright] :: Keys String
[Software] :: Keys String
[Comment] :: Keys String
[Disclaimer] :: Keys String
[Source] :: Keys String
[Warning] :: Keys String
[Exif] :: !ExifTag -> Keys ExifData
[Unknown] :: !String -> Keys Value

-- | Encode values for unknown information
data Value
Int :: !Int -> Value
Double :: !Double -> Value
String :: !String -> Value

-- | Element describing a metadata and it's (typed) associated value.
data Elem k
(:=>) :: !(k a) -> a -> Elem k

-- | Type describing the original file format of the ilfe.
data SourceFormat
SourceJpeg :: SourceFormat
SourceGif :: SourceFormat
SourceBitmap :: SourceFormat
SourceTiff :: SourceFormat
SourcePng :: SourceFormat
SourceHDR :: SourceFormat
SourceTGA :: SourceFormat

-- | Search a metadata with the given key.
lookup :: Keys a -> Metadatas -> Maybe a

-- | Empty metadatas. Favor <a>mempty</a>
empty :: Metadatas

-- | Insert an element in the metadatas, if an element with the same key is
--   present, it is overwritten.
insert :: (Show a, NFData a) => Keys a -> a -> Metadatas -> Metadatas

-- | Remove an element of the given keys from the metadatas. If not present
--   does nothing.
delete :: Keys a -> Metadatas -> Metadatas

-- | Create metadatas with a single element.
singleton :: (Show a, NFData a) => Keys a -> a -> Metadatas

-- | Strict left fold of the metadatas
foldl' :: (acc -> Elem Keys -> acc) -> acc -> Metadatas -> acc

-- | foldMap equivalent for metadatas.
foldMap :: Monoid m => (Elem Keys -> m) -> Metadatas -> m

-- | Create metadatas indicating the resolution, with DpiX == DpiY
mkDpiMetadata :: Word -> Metadatas

-- | Create metadatas holding width and height information.
mkSizeMetadata :: Integral n => n -> n -> Metadatas

-- | Create simple metadatas with Format, Width &amp; Height
basicMetadata :: Integral nSize => SourceFormat -> nSize -> nSize -> Metadatas

-- | Create simple metadatas with Format, Width, Height, DpiX &amp; DpiY
simpleMetadata :: (Integral nSize, Integral nDpi) => SourceFormat -> nSize -> nSize -> nDpi -> nDpi -> Metadatas

-- | Extract all Exif specific metadatas
extractExifMetas :: Metadatas -> [(ExifTag, ExifData)]

-- | Conversion from dpm to dpi
dotsPerMeterToDotPerInch :: Word -> Word

-- | Conversion from dpi to dpm
dotPerInchToDotsPerMeter :: Word -> Word

-- | Conversion dpcm -&gt; dpi
dotsPerCentiMeterToDotPerInch :: Word -> Word
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Metadatas
instance GHC.Show.Show Codec.Picture.Metadata.Metadatas
instance GHC.Show.Show Codec.Picture.Metadata.Value
instance GHC.Classes.Eq Codec.Picture.Metadata.Value
instance GHC.Show.Show Codec.Picture.Metadata.SourceFormat
instance GHC.Classes.Eq Codec.Picture.Metadata.SourceFormat
instance GHC.Show.Show (Codec.Picture.Metadata.Keys a)
instance GHC.Classes.Eq (Codec.Picture.Metadata.Keys a)
instance GHC.Show.Show (Codec.Picture.Metadata.Elem Codec.Picture.Metadata.Keys)
instance Control.DeepSeq.NFData Codec.Picture.Metadata.SourceFormat
instance Control.DeepSeq.NFData Codec.Picture.Metadata.Value
instance Control.DeepSeq.NFData (Codec.Picture.Metadata.Elem Codec.Picture.Metadata.Keys)
instance GHC.Base.Monoid Codec.Picture.Metadata.Metadatas


-- | Module used for loading &amp; writing 'Portable Network Graphics'
--   (PNG) files.
--   
--   A high level API is provided. It loads and saves images for you while
--   hiding all the details about PNG chunks.
--   
--   Basic functions for PNG handling are <a>decodePng</a>,
--   <a>encodePng</a> and <a>encodePalettedPng</a>. Convenience functions
--   are provided for direct file handling and using <a>DynamicImage</a>s.
--   
--   The loader has been validated against the pngsuite
--   (http:/<i>www.libpng.org</i>pub<i>png</i>pngsuite.html)
module Codec.Picture.Png

-- | Encode an image into a png if possible.
class PngSavable a where encodePng = encodePngWithMetadata mempty

-- | Transform an image into a png encoded bytestring, ready to be written
--   as a file.
encodePng :: PngSavable a => Image a -> ByteString

-- | Encode a png using some metadatas. The following metadata keys will be
--   stored in a <tt>tEXt</tt> field :
--   
--   <ul>
--   <li><a>Title</a></li>
--   <li><a>Description</a></li>
--   <li><a>Author</a></li>
--   <li><a>Copyright</a></li>
--   <li><a>Software</a></li>
--   <li><a>Comment</a></li>
--   <li><a>Disclaimer</a></li>
--   <li><a>Source</a></li>
--   <li><a>Warning</a></li>
--   <li><a>Unknown</a> using the key present in the constructor.</li>
--   </ul>
--   
--   the followings metadata will bes tored in the <tt>gAMA</tt> chunk.
--   
--   <ul>
--   <li><a>Gamma</a></li>
--   </ul>
--   
--   The followings metadata will be stored in a <tt>pHYs</tt> chunk
--   
--   <ul>
--   <li><a>DpiX</a></li>
--   <li><a>DpiY</a></li>
--   </ul>
encodePngWithMetadata :: PngSavable a => Metadatas -> Image a -> ByteString

-- | Encode a paletted image into a png if possible.
class PngPaletteSaveable a where encodePalettedPng = encodePalettedPngWithMetadata mempty

-- | Encode a paletted image as a color indexed 8-bit PNG. the palette must
--   have between 1 and 256 values in it. Accepts <a>PixelRGB8</a> and
--   <a>PixelRGBA8</a> as palette pixel type
encodePalettedPng :: PngPaletteSaveable a => Image a -> Image Pixel8 -> Either String ByteString

-- | Equivalent to <a>encodePalettedPng</a> but allow writing of metadatas.
--   See <a>encodePngWithMetadata</a> for the details of encoded metadatas
--   Accepts <a>PixelRGB8</a> and <a>PixelRGBA8</a> as palette pixel type
encodePalettedPngWithMetadata :: PngPaletteSaveable a => Metadatas -> Image a -> Image Pixel8 -> Either String ByteString

-- | Transform a raw png image to an image, without modifying the
--   underlying pixel type. If the image is greyscale and &lt; 8 bits, a
--   transformation to RGBA8 is performed. This should change in the
--   future. The resulting image let you manage the pixel types.
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageY16</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageYA16</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGB16</a></li>
--   <li><a>ImageRGBA8</a></li>
--   <li><a>ImageRGBA16</a></li>
--   </ul>
decodePng :: ByteString -> Either String DynamicImage

-- | Decode a PNG file with, possibly, separated palette.
decodePngWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Same as <a>decodePng</a> but also extract meta datas present in the
--   files.
decodePngWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)

-- | Helper function to directly write an image as a png on disk.
writePng :: (PngSavable pixel) => FilePath -> Image pixel -> IO ()

-- | Encode a dynamic image in PNG if possible, supported images are:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageY16</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageYA16</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGB16</a></li>
--   <li><a>ImageRGBA8</a></li>
--   <li><a>ImageRGBA16</a></li>
--   </ul>
encodeDynamicPng :: DynamicImage -> Either String ByteString

-- | Encode a paletted image as a color indexed 8-bit PNG. the palette must
--   have between 1 and 256 values in it. Accepts <a>PixelRGB8</a> and
--   <a>PixelRGBA8</a> as palette pixel type
encodePalettedPng :: PngPaletteSaveable a => Image a -> Image Pixel8 -> Either String ByteString

-- | Equivalent to <a>encodePalettedPng</a> but allow writing of metadatas.
--   See <a>encodePngWithMetadata</a> for the details of encoded metadatas
--   Accepts <a>PixelRGB8</a> and <a>PixelRGBA8</a> as palette pixel type
encodePalettedPngWithMetadata :: PngPaletteSaveable a => Metadatas -> Image a -> Image Pixel8 -> Either String ByteString

-- | Write a dynamic image in a .png image file if possible. The same
--   restriction as encodeDynamicPng apply.
writeDynamicPng :: FilePath -> DynamicImage -> IO (Either String Bool)


-- | Module implementing function to read and write Targa (*.tga) files.
module Codec.Picture.Tga

-- | Transform a raw tga image to an image, without modifying the
--   underlying pixel type.
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
decodeTga :: ByteString -> Either String DynamicImage

-- | Equivalent to decodeTga but also provide metadata
decodeTgaWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Equivalent to decodeTga but with metdata and palette if any
decodeTgaWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)

-- | This typeclass determine if a pixel can be saved in the TGA format.
class TgaSaveable a

-- | Transform a compatible image to a raw bytestring representing a Targa
--   file.
encodeTga :: (TgaSaveable px) => Image px -> ByteString

-- | Helper function to directly write an image a tga on disk.
writeTga :: (TgaSaveable pixel) => FilePath -> Image pixel -> IO ()
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaColorMapType
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaImageType
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaImageDescription
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaHeader
instance Data.Binary.Class.Binary Codec.Picture.Tga.TgaFile
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth8
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth15
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth24
instance Codec.Picture.Tga.TGAPixel Codec.Picture.Tga.Depth32
instance Codec.Picture.Tga.TgaSaveable Codec.Picture.Types.Pixel8
instance Codec.Picture.Tga.TgaSaveable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Tga.TgaSaveable Codec.Picture.Types.PixelRGBA8


-- | Module dedicated of Radiance file decompression (.hdr or .pic) file.
--   Radiance file format is used for High dynamic range imaging.
module Codec.Picture.HDR

-- | Decode an HDR (radiance) image, the resulting image can be:
--   
--   <ul>
--   <li><a>ImageRGBF</a></li>
--   </ul>
decodeHDR :: ByteString -> Either String DynamicImage

-- | Equivalent to decodeHDR but with aditional metadatas.
decodeHDRWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Encode an High dynamic range image into a radiance image file format.
--   Alias for encodeRawHDR
encodeHDR :: Image PixelRGBF -> ByteString

-- | Encode an High dynamic range image into a radiance image file format.
--   without compression
encodeRawHDR :: Image PixelRGBF -> ByteString

-- | Encode an High dynamic range image into a radiance image file format
--   using a light RLE compression. Some problems seem to arise with some
--   image viewer.
encodeRLENewStyleHDR :: Image PixelRGBF -> ByteString

-- | Write an High dynamic range image into a radiance image file on disk.
writeHDR :: FilePath -> Image PixelRGBF -> IO ()

-- | Write a RLE encoded High dynamic range image into a radiance image
--   file on disk.
writeRLENewStyleHDR :: FilePath -> Image PixelRGBF -> IO ()
instance Data.Binary.Class.Binary Codec.Picture.HDR.RGBE
instance Data.Binary.Class.Binary Codec.Picture.HDR.RadianceFormat
instance Data.Binary.Class.Binary Codec.Picture.HDR.RadianceHeader


-- | This module provide some color quantisation algorithm in order to help
--   in the creation of paletted images. The most important function is
--   <a>palettize</a> which will make everything to create a nice color
--   indexed image with its palette.
module Codec.Picture.ColorQuant

-- | Reduces an image to a color palette according to <tt>PaletteOpts</tt>
--   and returns the <i>indices image</i> along with its <a>Palette</a>.
palettize :: PaletteOptions -> Image PixelRGB8 -> (Image Pixel8, Palette)

-- | Default palette option, which aim at the best quality and maximum
--   possible colors (256)
defaultPaletteOptions :: PaletteOptions

-- | Define which palette creation method is used.
data PaletteCreationMethod

-- | MedianMeanCut method, provide the best results (visualy) at the cost
--   of increased calculations.
MedianMeanCut :: PaletteCreationMethod

-- | Very fast algorithm (one pass), doesn't provide good looking results.
Uniform :: PaletteCreationMethod

-- | To specify how the palette will be created.
data PaletteOptions
PaletteOptions :: PaletteCreationMethod -> Bool -> Int -> PaletteOptions

-- | Algorithm used to find the palette
[paletteCreationMethod] :: PaletteOptions -> PaletteCreationMethod

-- | Do we want to apply the dithering to the image. Enabling it often
--   reduce compression ratio but enhance the perceived quality of the
--   final image.
[enableImageDithering] :: PaletteOptions -> Bool

-- | Maximum number of color we want in the palette
[paletteColorCount] :: PaletteOptions -> Int
instance GHC.Base.Functor (Codec.Picture.ColorQuant.Fold a)
instance GHC.Base.Applicative (Codec.Picture.ColorQuant.Fold a)
instance GHC.Classes.Eq Codec.Picture.ColorQuant.Cluster
instance GHC.Classes.Ord Codec.Picture.ColorQuant.Cluster


-- | Modules used for Bitmap file (.bmp) file loading and writing
module Codec.Picture.Bitmap

-- | Write an image in a file use the bitmap format.
writeBitmap :: (BmpEncodable pixel) => FilePath -> Image pixel -> IO ()

-- | Encode an image into a bytestring in .bmp format ready to be written
--   on disk.
encodeBitmap :: forall pixel. (BmpEncodable pixel) => Image pixel -> ByteString

-- | Equivalent to <a>encodeBitmap</a> but also store the following
--   metadatas:
--   
--   <ul>
--   <li><a>DpiX</a></li>
--   <li><a>DpiY</a></li>
--   </ul>
encodeBitmapWithMetadata :: forall pixel. BmpEncodable pixel => Metadatas -> Image pixel -> ByteString

-- | Try to decode a bitmap image. Right now this function can output the
--   following image:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
decodeBitmap :: ByteString -> Either String DynamicImage

-- | Same as <a>decodeBitmap</a> but also extracts metadata.
decodeBitmapWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Same as <a>decodeBitmap</a> but also extracts metadata and provide
--   separated palette.
decodeBitmapWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)

-- | Encode a dynamic image in BMP if possible, supported images are:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
encodeDynamicBitmap :: DynamicImage -> Either String ByteString

-- | Equivalent to <a>encodeBitmapWithPalette</a> but also store the
--   following metadatas:
--   
--   <ul>
--   <li><a>DpiX</a></li>
--   <li><a>DpiY</a></li>
--   </ul>
encodeBitmapWithPaletteAndMetadata :: forall pixel. (BmpEncodable pixel) => Metadatas -> BmpPalette -> Image pixel -> ByteString

-- | Write a dynamic image in a .bmp image file if possible. The same
--   restriction as <a>encodeDynamicBitmap</a> apply.
writeDynamicBitmap :: FilePath -> DynamicImage -> IO (Either String Bool)

-- | All the instance of this class can be written as a bitmap file using
--   this library.
class BmpEncodable pixel where defaultPalette _ = BmpPalette []
instance GHC.Show.Show Codec.Picture.Bitmap.BmpInfoHeader
instance Data.Binary.Class.Binary Codec.Picture.Bitmap.BmpHeader
instance Data.Binary.Class.Binary Codec.Picture.Bitmap.BmpInfoHeader
instance Codec.Picture.Bitmap.BmpEncodable Codec.Picture.Types.Pixel8
instance Codec.Picture.Bitmap.BmpEncodable Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Bitmap.BmpEncodable Codec.Picture.Types.PixelRGB8


-- | Module implementing GIF decoding.
module Codec.Picture.Gif

-- | Transform a raw gif image to an image, without modifying the pixels.
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
decodeGif :: ByteString -> Either String DynamicImage

-- | Transform a raw gif image to an image, without modifying the pixels.
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
--   
--   Metadatas include Width &amp; Height information.
decodeGifWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Return the gif image with metadata and palette. The palette is only
--   returned for the first image of an animation and has no transparency.
decodeGifWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)

-- | Transform a raw gif to a list of images, representing all the images
--   of an animation.
decodeGifImages :: ByteString -> Either String [DynamicImage]

-- | Extract a list of frame delays from a raw gif.
getDelaysGifImages :: ByteString -> Either String [GifDelay]

-- | Delay to wait before showing the next Gif image. The delay is
--   expressed in 100th of seconds.
type GifDelay = Int

-- | Help to control the behaviour of GIF animation looping.
data GifLooping

-- | The animation will stop once the end is reached
LoopingNever :: GifLooping

-- | The animation will restart once the end is reached
LoopingForever :: GifLooping

-- | The animation will repeat n times before stoping
LoopingRepeat :: Word16 -> GifLooping

-- | Encode a greyscale image to a bytestring.
encodeGifImage :: Image Pixel8 -> ByteString

-- | Encode an image with a given palette. Can return errors if the palette
--   is ill-formed.
--   
--   <ul>
--   <li>A palette must have between 1 and 256 colors</li>
--   </ul>
encodeGifImageWithPalette :: Image Pixel8 -> Palette -> Either String ByteString

-- | Encode a gif animation to a bytestring.
--   
--   <ul>
--   <li>Every image must have the same size</li>
--   <li>Every palette must have between one and 256 colors.</li>
--   </ul>
encodeGifImages :: GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String ByteString

-- | Write a greyscale in a gif file on the disk.
writeGifImage :: FilePath -> Image Pixel8 -> IO ()

-- | Write a gif image with a palette to a file.
--   
--   <ul>
--   <li>A palette must have between 1 and 256 colors</li>
--   </ul>
writeGifImageWithPalette :: FilePath -> Image Pixel8 -> Palette -> Either String (IO ())

-- | Write a list of images as a gif animation in a file.
--   
--   <ul>
--   <li>Every image must have the same size</li>
--   <li>Every palette must have between one and 256 colors.</li>
--   </ul>
writeGifImages :: FilePath -> GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String (IO ())

-- | Default palette to produce greyscale images.
greyPalette :: Palette
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifVersion
instance Data.Binary.Class.Binary Codec.Picture.Gif.LogicalScreenDescriptor
instance Data.Binary.Class.Binary Codec.Picture.Gif.GraphicControlExtension
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifImage
instance Data.Binary.Class.Binary Codec.Picture.Gif.ImageDescriptor
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifHeader
instance Data.Binary.Class.Binary Codec.Picture.Gif.GifFile


-- | Module used for JPEG file loading and writing.
module Codec.Picture.Jpg

-- | Try to decompress and decode a jpeg file. The colorspace is still
--   YCbCr if you want to perform computation on the luma part. You can
--   convert it to RGB using <a>convertImage</a> from the
--   <a>ColorSpaceConvertible</a> typeclass.
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageCMYK8</a></li>
--   <li><a>ImageYCbCr8</a></li>
--   </ul>
decodeJpeg :: ByteString -> Either String DynamicImage

-- | Equivalent to <a>decodeJpeg</a> but also extracts metadatas.
--   
--   Extract the following metadatas from the JFIF block:
--   
--   <ul>
--   <li><a>DpiX</a></li>
--   <li><a>DpiY</a></li>
--   </ul>
--   
--   Exif metadata are also extracted if present.
decodeJpegWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Function to call to encode an image to jpeg. The quality factor should
--   be between 0 and 100 (100 being the best quality).
encodeJpegAtQuality :: Word8 -> Image PixelYCbCr8 -> ByteString

-- | Equivalent to <a>encodeJpegAtQuality</a>, but will store the following
--   metadatas in the file using a JFIF block:
--   
--   <ul>
--   <li><a>DpiX</a></li>
--   <li><a>DpiY</a></li>
--   </ul>
encodeJpegAtQualityWithMetadata :: Word8 -> Metadatas -> Image PixelYCbCr8 -> ByteString

-- | Equivalent to <a>encodeJpegAtQuality</a>, but will store the following
--   metadatas in the file using a JFIF block:
--   
--   <ul>
--   <li><a>DpiX</a></li>
--   <li><a>DpiY</a></li>
--   </ul>
--   
--   This function also allow to create JPEG files with the following color
--   space:
--   
--   <ul>
--   <li>Y (<a>Pixel8</a>) for greyscale.</li>
--   <li>RGB (<a>PixelRGB8</a>) with no color downsampling on any
--   plane</li>
--   <li>CMYK (<a>PixelCMYK8</a>) with no color downsampling on any
--   plane</li>
--   </ul>
encodeDirectJpegAtQualityWithMetadata :: forall px. (JpgEncodable px) => Word8 -> Metadatas -> Image px -> ByteString

-- | Encode an image in jpeg at a reasonnable quality level. If you want
--   better quality or reduced file size, you should use
--   <a>encodeJpegAtQuality</a>
encodeJpeg :: Image PixelYCbCr8 -> ByteString

-- | Helper type class describing all JPG-encodable pixel types
class (Pixel px, PixelBaseComponent px ~ Word8) => JpgEncodable px where additionalBlocks _ = [] imageHuffmanTables _ = defaultHuffmanTables quantTableSpec _ qual = take 1 $ zigzaggedQuantificationSpec qual maximumSubSamplingOf _ = 1
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.Pixel8
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.PixelYCbCr8
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Jpg.JpgEncodable Codec.Picture.Types.PixelCMYK8


-- | Module implementing TIFF decoding.
--   
--   Supported compression schemes:
--   
--   <ul>
--   <li>Uncompressed</li>
--   <li>PackBits</li>
--   <li>LZW</li>
--   </ul>
--   
--   Supported bit depth:
--   
--   <ul>
--   <li>2 bits</li>
--   <li>4 bits</li>
--   <li>8 bits</li>
--   <li>16 bits</li>
--   </ul>
module Codec.Picture.Tiff

-- | Decode a tiff encoded image while preserving the underlying pixel type
--   (except for Y32 which is truncated to 16 bits).
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageY16</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageYA16</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGB16</a></li>
--   <li><a>ImageRGBA8</a></li>
--   <li><a>ImageRGBA16</a></li>
--   <li><a>ImageCMYK8</a></li>
--   <li><a>ImageCMYK16</a></li>
--   </ul>
decodeTiff :: ByteString -> Either String DynamicImage

-- | Like <a>decodeTiff</a> but also provides some metdata present in the
--   Tiff file.
--   
--   The metadata extracted are the <a>DpiX</a> &amp; <a>DpiY</a>
--   information alongside the EXIF informations.
decodeTiffWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Decode TIFF and provide separated palette and metadata
decodeTiffWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)

-- | Class defining which pixel types can be serialized in a Tiff file.
class (Pixel px) => TiffSaveable px where extraSampleCodeOfPixel _ = Nothing subSamplingInfo _ = empty

-- | Transform an image into a Tiff encoded bytestring, ready to be written
--   as a file.
encodeTiff :: forall px. (TiffSaveable px) => Image px -> ByteString

-- | Helper function to directly write an image as a tiff on disk.
writeTiff :: (TiffSaveable pixel) => FilePath -> Image pixel -> IO ()
instance Codec.Picture.Tiff.Unpackable GHC.Word.Word8
instance Codec.Picture.Tiff.Unpackable GHC.Word.Word16
instance Codec.Picture.Tiff.Unpackable GHC.Word.Word32
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.Pack4
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.Pack2
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.Pack12
instance Codec.Picture.Tiff.Unpackable Codec.Picture.Tiff.YCbCrSubsampling
instance Codec.Picture.Tiff.Types.BinaryParam Data.ByteString.Internal.ByteString Codec.Picture.Tiff.TiffInfo
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.Pixel8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.Pixel16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelYA8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelYA16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelCMYK16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGB16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelRGBA16
instance Codec.Picture.Tiff.TiffSaveable Codec.Picture.Types.PixelYCbCr8


-- | Helper functions to save dynamic images to other file format with
--   automatic color space/sample format conversion done automatically.
module Codec.Picture.Saving

-- | This function will try to do anything to encode an image as JPEG, make
--   all color conversion and such. Equivalent of <tt>decodeImage</tt> for
--   jpeg encoding Save Y or YCbCr Jpeg only, all other colorspaces are
--   converted. To save a RGB or CMYK JPEG file, use the
--   <a>encodeDirectJpegAtQualityWithMetadata</a> function
imageToJpg :: Int -> DynamicImage -> ByteString

-- | This function will try to do anything to encode an image as PNG, make
--   all color conversion and such. Equivalent of <tt>decodeImage</tt> for
--   PNG encoding
imageToPng :: DynamicImage -> ByteString

-- | This function will try to do anything to encode an image as a gif,
--   make all color conversion and quantization. Equivalent of
--   <tt>decodeImage</tt> for gif encoding
imageToGif :: DynamicImage -> Either String ByteString

-- | This function will try to do anything to encode an image as bitmap,
--   make all color conversion and such. Equivalent of <tt>decodeImage</tt>
--   for Bitmap encoding
imageToBitmap :: DynamicImage -> ByteString

-- | This function will try to do anything to encode an image as a Tiff,
--   make all color conversion and such. Equivalent of <tt>decodeImage</tt>
--   for Tiff encoding
imageToTiff :: DynamicImage -> ByteString

-- | This function will try to do anything to encode an image as RADIANCE,
--   make all color conversion and such. Equivalent of <tt>decodeImage</tt>
--   for radiance encoding
imageToRadiance :: DynamicImage -> ByteString

-- | This function will try to do anything to encode an image as a tga,
--   make all color conversion and quantization. Equivalent of
--   <tt>decodeImage</tt> for tga encoding
imageToTga :: DynamicImage -> ByteString


-- | Main module for image import/export into various image formats.
--   
--   To use the library without thinking about it, look after
--   <a>decodeImage</a> and <a>readImage</a>.
--   
--   Generally, the <tt>read*</tt> functions read the images from a file
--   and try to decode it, and the <tt>decode*</tt> functions try to decode
--   a bytestring.
--   
--   For an easy image writing use the <a>saveBmpImage</a>,
--   <a>saveJpgImage</a> &amp; <a>savePngImage</a> functions
module Codec.Picture

-- | Load an image file without even thinking about it, it does everything
--   as <a>decodeImage</a>
readImage :: FilePath -> IO (Either String DynamicImage)

-- | Equivalent to <a>readImage</a> but also providing metadatas.
readImageWithMetadata :: FilePath -> IO (Either String (DynamicImage, Metadatas))

-- | If you want to decode an image in a bytestring without even thinking
--   in term of format or whatever, this is the function to use. It will
--   try to decode in each known format and if one decoding succeeds, it
--   will return the decoded image in it's own colorspace.
decodeImage :: ByteString -> Either String DynamicImage

-- | Equivalent to <a>decodeImage</a>, but also provide potential metadatas
--   present in the given file.
decodeImageWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)

-- | Equivalent to <a>decodeImage</a>, but also provide potential metadatas
--   present in the given file and the palettes if the format provides
--   them.
decodeImageWithPaletteAndMetadata :: ByteString -> Either String (PalettedImage, Metadatas)

-- | <a>map</a> equivalent for an image, working at the pixel level. Little
--   example : a brightness function for an rgb image
--   
--   <pre>
--   brightnessRGB8 :: Int -&gt; Image PixelRGB8 -&gt; Image PixelRGB8
--   brightnessRGB8 add = pixelMap brightFunction
--        where up v = fromIntegral (fromIntegral v + add)
--              brightFunction (PixelRGB8 r g b) =
--                      PixelRGB8 (up r) (up g) (up b)
--   </pre>
pixelMap :: forall a b. (Pixel a, Pixel b) => (a -> b) -> Image a -> Image b

-- | Create an image given a function to generate pixels. The function will
--   receive values from 0 to width-1 for the x parameter and 0 to height-1
--   for the y parameter. The coordinates 0,0 are the upper left corner of
--   the image, and (width-1, height-1) the lower right corner.
--   
--   for example, to create a small gradient image:
--   
--   <pre>
--   imageCreator :: String -&gt; IO ()
--   imageCreator path = writePng path $ generateImage pixelRenderer 250 300
--      where pixelRenderer x y = PixelRGB8 (fromIntegral x) (fromIntegral y) 128
--   </pre>
generateImage :: forall px. (Pixel px) => (Int -> Int -> px) -> Int -> Int -> Image px

-- | Create an image given a function to generate pixels. The function will
--   receive values from 0 to width-1 for the x parameter and 0 to height-1
--   for the y parameter. The coordinates 0,0 are the upper left corner of
--   the image, and (width-1, height-1) the lower right corner.
--   
--   the acc parameter is a user defined one.
--   
--   The function is called for each pixel in the line from left to right
--   (0 to width - 1) and for each line (0 to height - 1).
generateFoldImage :: forall a acc. (Pixel a) => (acc -> Int -> Int -> (acc, a)) -> acc -> Int -> Int -> (acc, Image a)

-- | Create an image using a monadic initializer function. The function
--   will receive values from 0 to width-1 for the x parameter and 0 to
--   height-1 for the y parameter. The coordinates 0,0 are the upper left
--   corner of the image, and (width-1, height-1) the lower right corner.
--   
--   The function is called for each pixel in the line from left to right
--   (0 to width - 1) and for each line (0 to height - 1).
withImage :: forall m pixel. (Pixel pixel, PrimMonad m) => Int -> Int -> (Int -> Int -> m pixel) -> m (Image pixel)

-- | Flatten a PalettedImage to a DynamicImage
palettedToTrueColor :: PalettedImage -> DynamicImage

-- | Convert by any mean possible a dynamic image to an image in RGB. The
--   process can lose precision while converting from 16bits pixels or
--   Floating point pixels. Any alpha layer will be dropped
convertRGB8 :: DynamicImage -> Image PixelRGB8

-- | Convert by any mean possible a dynamic image to an image in RGBA. The
--   process can lose precision while converting from 16bits pixels or
--   Floating point pixels.
convertRGBA8 :: DynamicImage -> Image PixelRGBA8

-- | Traversal type matching the definition in the Lens package.
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t

-- | Traversal in "raster" order, from left to right the top to bottom.
--   This traversal is matching pixelMap in spirit.
--   
--   Since 3.2.4
imagePixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) pxa pxb

-- | Traversal providing the pixel position with it's value. The traversal
--   in raster order, from lef to right, then top to bottom. The traversal
--   match pixelMapXY in spirit.
--   
--   Since 3.2.4
imageIPixels :: forall pxa pxb. (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) (Int, Int, pxa) pxb

-- | Save an image to a '.bmp' file, will do everything it can to save an
--   image.
saveBmpImage :: FilePath -> DynamicImage -> IO ()

-- | Save an image to a '.jpg' file, will do everything it can to save an
--   image.
saveJpgImage :: Int -> FilePath -> DynamicImage -> IO ()

-- | Save an image to a '.gif' file, will do everything it can to save it.
saveGifImage :: FilePath -> DynamicImage -> Either String (IO ())

-- | Save an image to a '.png' file, will do everything it can to save an
--   image. For example, a simple transcoder to png
--   
--   <pre>
--   transcodeToPng :: FilePath -&gt; FilePath -&gt; IO ()
--   transcodeToPng pathIn pathOut = do
--      eitherImg &lt;- readImage pathIn
--      case eitherImg of
--          Left _ -&gt; return ()
--          Right img -&gt; savePngImage pathOut img
--   </pre>
savePngImage :: FilePath -> DynamicImage -> IO ()

-- | Save an image to a '.tiff' file, will do everything it can to save an
--   image.
saveTiffImage :: FilePath -> DynamicImage -> IO ()

-- | Save an image to a '.hdr' file, will do everything it can to save an
--   image.
saveRadianceImage :: FilePath -> DynamicImage -> IO ()

-- | All the instance of this class can be written as a bitmap file using
--   this library.
class BmpEncodable pixel where defaultPalette _ = BmpPalette []

-- | Write an image in a file use the bitmap format.
writeBitmap :: (BmpEncodable pixel) => FilePath -> Image pixel -> IO ()

-- | Encode an image into a bytestring in .bmp format ready to be written
--   on disk.
encodeBitmap :: forall pixel. (BmpEncodable pixel) => Image pixel -> ByteString

-- | Try to load a .bmp file. The colorspace would be RGB, RGBA or Y.
readBitmap :: FilePath -> IO (Either String DynamicImage)

-- | Try to decode a bitmap image. Right now this function can output the
--   following image:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
decodeBitmap :: ByteString -> Either String DynamicImage

-- | Encode a dynamic image in BMP if possible, supported images are:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
encodeDynamicBitmap :: DynamicImage -> Either String ByteString

-- | Write a dynamic image in a .bmp image file if possible. The same
--   restriction as <a>encodeDynamicBitmap</a> apply.
writeDynamicBitmap :: FilePath -> DynamicImage -> IO (Either String Bool)

-- | Helper function trying to load a gif file from a file on disk.
readGif :: FilePath -> IO (Either String DynamicImage)

-- | Helper function trying to load all the images of an animated gif file.
readGifImages :: FilePath -> IO (Either String [DynamicImage])

-- | Transform a raw gif image to an image, without modifying the pixels.
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
decodeGif :: ByteString -> Either String DynamicImage

-- | Transform a raw gif to a list of images, representing all the images
--   of an animation.
decodeGifImages :: ByteString -> Either String [DynamicImage]

-- | Encode a greyscale image to a bytestring.
encodeGifImage :: Image Pixel8 -> ByteString

-- | Write a greyscale in a gif file on the disk.
writeGifImage :: FilePath -> Image Pixel8 -> IO ()

-- | Encode an image with a given palette. Can return errors if the palette
--   is ill-formed.
--   
--   <ul>
--   <li>A palette must have between 1 and 256 colors</li>
--   </ul>
encodeGifImageWithPalette :: Image Pixel8 -> Palette -> Either String ByteString

-- | Write a gif image with a palette to a file.
--   
--   <ul>
--   <li>A palette must have between 1 and 256 colors</li>
--   </ul>
writeGifImageWithPalette :: FilePath -> Image Pixel8 -> Palette -> Either String (IO ())

-- | Encode a full color image to a gif by applying a color quantization
--   algorithm on it.
encodeColorReducedGifImage :: Image PixelRGB8 -> Either String ByteString

-- | Write a full color image to a gif by applying a color quantization
--   algorithm on it.
writeColorReducedGifImage :: FilePath -> Image PixelRGB8 -> Either String (IO ())

-- | Encode a gif animation to a bytestring.
--   
--   <ul>
--   <li>Every image must have the same size</li>
--   <li>Every palette must have between one and 256 colors.</li>
--   </ul>
encodeGifImages :: GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String ByteString

-- | Write a list of images as a gif animation in a file.
--   
--   <ul>
--   <li>Every image must have the same size</li>
--   <li>Every palette must have between one and 256 colors.</li>
--   </ul>
writeGifImages :: FilePath -> GifLooping -> [(Palette, GifDelay, Image Pixel8)] -> Either String (IO ())

-- | Delay to wait before showing the next Gif image. The delay is
--   expressed in 100th of seconds.
type GifDelay = Int

-- | Help to control the behaviour of GIF animation looping.
data GifLooping

-- | The animation will stop once the end is reached
LoopingNever :: GifLooping

-- | The animation will restart once the end is reached
LoopingForever :: GifLooping

-- | The animation will repeat n times before stoping
LoopingRepeat :: Word16 -> GifLooping

-- | Helper function to create a gif animation. All the images of the
--   animation are separated by the same delay.
encodeGifAnimation :: GifDelay -> GifLooping -> [Image PixelRGB8] -> Either String ByteString

-- | Helper function to write a gif animation on disk. See
--   encodeGifAnimation
writeGifAnimation :: FilePath -> GifDelay -> GifLooping -> [Image PixelRGB8] -> Either String (IO ())

-- | Try to load a jpeg file and decompress. The colorspace is still YCbCr
--   if you want to perform computation on the luma part. You can convert
--   it to RGB using <tt>colorSpaceConversion</tt>.
readJpeg :: FilePath -> IO (Either String DynamicImage)

-- | Try to decompress and decode a jpeg file. The colorspace is still
--   YCbCr if you want to perform computation on the luma part. You can
--   convert it to RGB using <a>convertImage</a> from the
--   <a>ColorSpaceConvertible</a> typeclass.
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageCMYK8</a></li>
--   <li><a>ImageYCbCr8</a></li>
--   </ul>
decodeJpeg :: ByteString -> Either String DynamicImage

-- | Encode an image in jpeg at a reasonnable quality level. If you want
--   better quality or reduced file size, you should use
--   <a>encodeJpegAtQuality</a>
encodeJpeg :: Image PixelYCbCr8 -> ByteString

-- | Function to call to encode an image to jpeg. The quality factor should
--   be between 0 and 100 (100 being the best quality).
encodeJpegAtQuality :: Word8 -> Image PixelYCbCr8 -> ByteString

-- | Encode an image into a png if possible.
class PngSavable a where encodePng = encodePngWithMetadata mempty

-- | Transform an image into a png encoded bytestring, ready to be written
--   as a file.
encodePng :: PngSavable a => Image a -> ByteString

-- | Encode a png using some metadatas. The following metadata keys will be
--   stored in a <tt>tEXt</tt> field :
--   
--   <ul>
--   <li><a>Title</a></li>
--   <li><a>Description</a></li>
--   <li><a>Author</a></li>
--   <li><a>Copyright</a></li>
--   <li><a>Software</a></li>
--   <li><a>Comment</a></li>
--   <li><a>Disclaimer</a></li>
--   <li><a>Source</a></li>
--   <li><a>Warning</a></li>
--   <li><a>Unknown</a> using the key present in the constructor.</li>
--   </ul>
--   
--   the followings metadata will bes tored in the <tt>gAMA</tt> chunk.
--   
--   <ul>
--   <li><a>Gamma</a></li>
--   </ul>
--   
--   The followings metadata will be stored in a <tt>pHYs</tt> chunk
--   
--   <ul>
--   <li><a>DpiX</a></li>
--   <li><a>DpiY</a></li>
--   </ul>
encodePngWithMetadata :: PngSavable a => Metadatas -> Image a -> ByteString

-- | Helper function trying to load a png file from a file on disk.
readPng :: FilePath -> IO (Either String DynamicImage)

-- | Transform a raw png image to an image, without modifying the
--   underlying pixel type. If the image is greyscale and &lt; 8 bits, a
--   transformation to RGBA8 is performed. This should change in the
--   future. The resulting image let you manage the pixel types.
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageY16</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageYA16</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGB16</a></li>
--   <li><a>ImageRGBA8</a></li>
--   <li><a>ImageRGBA16</a></li>
--   </ul>
decodePng :: ByteString -> Either String DynamicImage

-- | Helper function to directly write an image as a png on disk.
writePng :: (PngSavable pixel) => FilePath -> Image pixel -> IO ()

-- | Encode a paletted image as a color indexed 8-bit PNG. the palette must
--   have between 1 and 256 values in it. Accepts <a>PixelRGB8</a> and
--   <a>PixelRGBA8</a> as palette pixel type
encodePalettedPng :: PngPaletteSaveable a => Image a -> Image Pixel8 -> Either String ByteString

-- | Encode a dynamic image in PNG if possible, supported images are:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageY16</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageYA16</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGB16</a></li>
--   <li><a>ImageRGBA8</a></li>
--   <li><a>ImageRGBA16</a></li>
--   </ul>
encodeDynamicPng :: DynamicImage -> Either String ByteString

-- | Write a dynamic image in a .png image file if possible. The same
--   restriction as encodeDynamicPng apply.
writeDynamicPng :: FilePath -> DynamicImage -> IO (Either String Bool)

-- | Try to load a .tga file from disk.
readTGA :: FilePath -> IO (Either String DynamicImage)

-- | Transform a raw tga image to an image, without modifying the
--   underlying pixel type.
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGBA8</a></li>
--   </ul>
decodeTga :: ByteString -> Either String DynamicImage

-- | This typeclass determine if a pixel can be saved in the TGA format.
class TgaSaveable a

-- | Transform a compatible image to a raw bytestring representing a Targa
--   file.
encodeTga :: (TgaSaveable px) => Image px -> ByteString

-- | Helper function to directly write an image a tga on disk.
writeTga :: (TgaSaveable pixel) => FilePath -> Image pixel -> IO ()

-- | Helper function trying to load tiff file from a file on disk.
readTiff :: FilePath -> IO (Either String DynamicImage)

-- | Class defining which pixel types can be serialized in a Tiff file.
class (Pixel px) => TiffSaveable px where extraSampleCodeOfPixel _ = Nothing subSamplingInfo _ = empty

-- | Decode a tiff encoded image while preserving the underlying pixel type
--   (except for Y32 which is truncated to 16 bits).
--   
--   This function can output the following images:
--   
--   <ul>
--   <li><a>ImageY8</a></li>
--   <li><a>ImageY16</a></li>
--   <li><a>ImageYA8</a></li>
--   <li><a>ImageYA16</a></li>
--   <li><a>ImageRGB8</a></li>
--   <li><a>ImageRGB16</a></li>
--   <li><a>ImageRGBA8</a></li>
--   <li><a>ImageRGBA16</a></li>
--   <li><a>ImageCMYK8</a></li>
--   <li><a>ImageCMYK16</a></li>
--   </ul>
decodeTiff :: ByteString -> Either String DynamicImage

-- | Transform an image into a Tiff encoded bytestring, ready to be written
--   as a file.
encodeTiff :: forall px. (TiffSaveable px) => Image px -> ByteString

-- | Helper function to directly write an image as a tiff on disk.
writeTiff :: (TiffSaveable pixel) => FilePath -> Image pixel -> IO ()

-- | Try to load a .pic file. The colorspace can only be RGB with floating
--   point precision.
readHDR :: FilePath -> IO (Either String DynamicImage)

-- | Decode an HDR (radiance) image, the resulting image can be:
--   
--   <ul>
--   <li><a>ImageRGBF</a></li>
--   </ul>
decodeHDR :: ByteString -> Either String DynamicImage

-- | Encode an High dynamic range image into a radiance image file format.
--   Alias for encodeRawHDR
encodeHDR :: Image PixelRGBF -> ByteString

-- | Write an High dynamic range image into a radiance image file on disk.
writeHDR :: FilePath -> Image PixelRGBF -> IO ()

-- | Define which palette creation method is used.
data PaletteCreationMethod

-- | MedianMeanCut method, provide the best results (visualy) at the cost
--   of increased calculations.
MedianMeanCut :: PaletteCreationMethod

-- | Very fast algorithm (one pass), doesn't provide good looking results.
Uniform :: PaletteCreationMethod

-- | To specify how the palette will be created.
data PaletteOptions
PaletteOptions :: PaletteCreationMethod -> Bool -> Int -> PaletteOptions

-- | Algorithm used to find the palette
[paletteCreationMethod] :: PaletteOptions -> PaletteCreationMethod

-- | Do we want to apply the dithering to the image. Enabling it often
--   reduce compression ratio but enhance the perceived quality of the
--   final image.
[enableImageDithering] :: PaletteOptions -> Bool

-- | Maximum number of color we want in the palette
[paletteColorCount] :: PaletteOptions -> Int

-- | Reduces an image to a color palette according to <tt>PaletteOpts</tt>
--   and returns the <i>indices image</i> along with its <a>Palette</a>.
palettize :: PaletteOptions -> Image PixelRGB8 -> (Image Pixel8, Palette)

-- | The main type of this package, one that most functions work on, is
--   Image.
--   
--   Parameterized by the underlying pixel format it forms a rigid type. If
--   you wish to store images of different or unknown pixel formats use
--   <a>DynamicImage</a>.
--   
--   Image is essentially a rectangular pixel buffer of specified width and
--   height. The coordinates are assumed to start from the upper-left
--   corner of the image, with the horizontal position first and vertical
--   second.
data Image a
Image :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Vector (PixelBaseComponent a) -> Image a

-- | Width of the image in pixels
[imageWidth] :: Image a -> {-# UNPACK #-} !Int

-- | Height of the image in pixels.
[imageHeight] :: Image a -> {-# UNPACK #-} !Int

-- | Image pixel data. To extract pixels at a given position you should use
--   the helper functions.
--   
--   Internally pixel data is stored as consecutively packed lines from top
--   to bottom, scanned from left to right within individual lines, from
--   first to last color component within each pixel.
[imageData] :: Image a -> Vector (PixelBaseComponent a)

-- | Image type enumerating all predefined pixel types. It enables loading
--   and use of images of different pixel types.
data DynamicImage

-- | A greyscale image.
ImageY8 :: (Image Pixel8) -> DynamicImage

-- | A greyscale image with 16bit components
ImageY16 :: (Image Pixel16) -> DynamicImage

-- | A greyscale HDR image
ImageYF :: (Image PixelF) -> DynamicImage

-- | An image in greyscale with an alpha channel.
ImageYA8 :: (Image PixelYA8) -> DynamicImage

-- | An image in greyscale with alpha channel on 16 bits.
ImageYA16 :: (Image PixelYA16) -> DynamicImage

-- | An image in true color.
ImageRGB8 :: (Image PixelRGB8) -> DynamicImage

-- | An image in true color with 16bit depth.
ImageRGB16 :: (Image PixelRGB16) -> DynamicImage

-- | An image with HDR pixels
ImageRGBF :: (Image PixelRGBF) -> DynamicImage

-- | An image in true color and an alpha channel.
ImageRGBA8 :: (Image PixelRGBA8) -> DynamicImage

-- | A true color image with alpha on 16 bits.
ImageRGBA16 :: (Image PixelRGBA16) -> DynamicImage

-- | An image in the colorspace used by Jpeg images.
ImageYCbCr8 :: (Image PixelYCbCr8) -> DynamicImage

-- | An image in the colorspace CMYK
ImageCMYK8 :: (Image PixelCMYK8) -> DynamicImage

-- | An image in the colorspace CMYK and 16 bits precision
ImageCMYK16 :: (Image PixelCMYK16) -> DynamicImage

-- | Type for the palette used in Gif &amp; PNG files.
type Palette = Image PixelRGB8

-- | Definition of pixels used in images. Each pixel has a color space, and
--   a representative component (Word8 or Float).
class (Storable (PixelBaseComponent a), Num (PixelBaseComponent a), Eq a) => Pixel a where type PixelBaseComponent a :: * mixWithAlpha f _ = mixWith f pixelBaseIndex (Image {imageWidth = w}) x y = (x + y * w) * componentCount (undefined :: a) mutablePixelBaseIndex (MutableImage {mutableImageWidth = w}) x y = (x + y * w) * componentCount (undefined :: a) where {
    type family PixelBaseComponent a :: *;
}

-- | Call the function for every component of the pixels. For example for
--   RGB pixels mixWith is declared like this:
--   
--   <pre>
--   mixWith f (PixelRGB8 ra ga ba) (PixelRGB8 rb gb bb) =
--      PixelRGB8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb)
--   </pre>
mixWith :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a

-- | Extension of the <a>mixWith</a> which separate the treatment of the
--   color components of the alpha value (transparency component). For
--   pixel without alpha components, it is equivalent to mixWith.
--   
--   <pre>
--   mixWithAlpha f fa (PixelRGBA8 ra ga ba aa) (PixelRGB8 rb gb bb ab) =
--      PixelRGBA8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) (fa aa ab)
--   </pre>
mixWithAlpha :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> (PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a

-- | Return the opacity of a pixel, if the pixel has an alpha layer, return
--   the alpha value. If the pixel doesn't have an alpha value, return a
--   value representing the opaqueness.
pixelOpacity :: Pixel a => a -> PixelBaseComponent a

-- | Return the number of components of the pixel
componentCount :: Pixel a => a -> Int

-- | Apply a function to each component of a pixel. If the color type
--   possess an alpha (transparency channel), it is treated like the other
--   color components.
colorMap :: Pixel a => (PixelBaseComponent a -> PixelBaseComponent a) -> a -> a

-- | Calculate the index for the begining of the pixel
pixelBaseIndex :: Pixel a => Image a -> Int -> Int -> Int

-- | Calculate theindex for the begining of the pixel at position x y
mutablePixelBaseIndex :: Pixel a => MutableImage s a -> Int -> Int -> Int

-- | Extract a pixel at a given position, (x, y), the origin is assumed to
--   be at the corner top left, positive y to the bottom of the image
pixelAt :: Pixel a => Image a -> Int -> Int -> a

-- | Same as pixelAt but for mutable images.
readPixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> m a

-- | Write a pixel in a mutable image at position x y
writePixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> a -> m ()

-- | Unsafe version of pixelAt, read a pixel at the given index without
--   bound checking (if possible). The index is expressed in number
--   (PixelBaseComponent a)
unsafePixelAt :: Pixel a => Vector (PixelBaseComponent a) -> Int -> a

-- | Unsafe version of readPixel, read a pixel at the given position
--   without bound checking (if possible). The index is expressed in number
--   (PixelBaseComponent a)
unsafeReadPixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> m a

-- | Unsafe version of writePixel, write a pixel at the given position
--   without bound checking. This can be _really_ unsafe. The index is
--   expressed in number (PixelBaseComponent a)
unsafeWritePixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> a -> m ()

-- | Type alias for 8bit greyscale pixels. For simplicity, greyscale pixels
--   use plain numbers instead of a separate type.
type Pixel8 = Word8

-- | Type alias for 16bit greyscale pixels.
type Pixel16 = Word16

-- | Type alias for 32bit floating point greyscale pixels. The standard
--   bounded value range is mapped to the closed interval [0,1] i.e.
--   
--   <pre>
--   map promotePixel [0, 1 .. 255 :: Pixel8] == [0/255, 1/255 .. 1.0 :: PixelF]
--   </pre>
type PixelF = Float

-- | Pixel type storing 8bit Luminance (Y) and alpha (A) information.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Luminance</li>
--   <li>Alpha</li>
--   </ul>
data PixelYA8
PixelYA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYA8

-- | Pixel type storing 16bit Luminance (Y) and alpha (A) information.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Luminance</li>
--   <li>Alpha</li>
--   </ul>
data PixelYA16
PixelYA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelYA16

-- | Classic pixel type storing 8bit red, green and blue (RGB) information.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   </ul>
data PixelRGB8
PixelRGB8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGB8

-- | Pixel type storing 16bit red, green and blue (RGB) information. Values
--   are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   </ul>
data PixelRGB16
PixelRGB16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGB16

-- | HDR pixel type storing floating point 32bit red, green and blue (RGB)
--   information. Same value range and comments apply as for <a>PixelF</a>.
--   Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   </ul>
data PixelRGBF
PixelRGBF :: {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> {-# UNPACK #-} !PixelF -> PixelRGBF

-- | Classical pixel type storing 8bit red, green, blue and alpha (RGBA)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   <li>Alpha</li>
--   </ul>
data PixelRGBA8
PixelRGBA8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGBA8

-- | Pixel type storing 16bit red, green, blue and alpha (RGBA)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Red</li>
--   <li>Green</li>
--   <li>Blue</li>
--   <li>Alpha</li>
--   </ul>
data PixelRGBA16
PixelRGBA16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelRGBA16

-- | Pixel type storing 8bit luminance, blue difference and red difference
--   (YCbCr) information. Values are stored in the following order:
--   
--   <ul>
--   <li>Y (luminance)</li>
--   <li>Cb</li>
--   <li>Cr</li>
--   </ul>
data PixelYCbCr8
PixelYCbCr8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelYCbCr8

-- | Pixel type storing 8bit cyan, magenta, yellow and black (CMYK)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Cyan</li>
--   <li>Magenta</li>
--   <li>Yellow</li>
--   <li>Black</li>
--   </ul>
data PixelCMYK8
PixelCMYK8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelCMYK8

-- | Pixel type storing 16bit cyan, magenta, yellow and black (CMYK)
--   information. Values are stored in the following order:
--   
--   <ul>
--   <li>Cyan</li>
--   <li>Magenta</li>
--   <li>Yellow</li>
--   <li>Black</li>
--   </ul>
data PixelCMYK16
PixelCMYK16 :: {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> {-# UNPACK #-} !Pixel16 -> PixelCMYK16

-- | Import a image from an unsafe pointer The pointer must have a size of
--   width * height * componentCount px
imageFromUnsafePtr :: forall px. (Pixel px, (PixelBaseComponent px) ~ Word8) => Int -> Int -> ForeignPtr Word8 -> Image px
instance Codec.Picture.Decimable Codec.Picture.Types.Pixel16 Codec.Picture.Types.Pixel8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PixelYA8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelRGB8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PixelRGBA8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PixelCMYK8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelF Codec.Picture.Types.Pixel8
instance Codec.Picture.Decimable Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PixelRGB8