Mercurial > hg > forks > libbpg
comparison bpgenc.c @ 12:9b00d4206f99
Implement support for one type of grayscale TIFF.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 08 Dec 2016 22:41:01 +0200 |
parents | e70eb0e6acd5 |
children | df9f2fee4285 |
comparison
equal
deleted
inserted
replaced
11:e70eb0e6acd5 | 12:9b00d4206f99 |
---|---|
982 TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img_pmetric); | 982 TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img_pmetric); |
983 | 983 |
984 // Check basics | 984 // Check basics |
985 switch (img_pmetric) | 985 switch (img_pmetric) |
986 { | 986 { |
987 case PHOTOMETRIC_MINISBLACK: | |
988 img_format = BPG_FORMAT_GRAY; | |
989 color_space = BPG_CS_YCbCr; | |
990 if (img_spp != 1) | |
991 err_spp = 1; | |
992 break; | |
993 | |
987 case PHOTOMETRIC_RGB: | 994 case PHOTOMETRIC_RGB: |
988 img_format = BPG_FORMAT_444; | 995 img_format = BPG_FORMAT_444; |
989 if (img_spp < 3) | 996 if (img_spp < 3) |
990 err_spp = 1; | 997 err_spp = 1; |
991 break; | 998 break; |
1103 else | 1110 else |
1104 { | 1111 { |
1105 gray8_to_gray(&cvt, | 1112 gray8_to_gray(&cvt, |
1106 (PIXEL *)(img->data[3] + y * img->linesize[3]), | 1113 (PIXEL *)(img->data[3] + y * img->linesize[3]), |
1107 ((uint8_t *) buf) + 3, img->w, 4); | 1114 ((uint8_t *) buf) + 3, img->w, 4); |
1115 } | |
1116 } | |
1117 break; | |
1118 | |
1119 case PHOTOMETRIC_MINISBLACK: | |
1120 if (img_depth == 16) | |
1121 { | |
1122 luma16_to_gray(&cvt, | |
1123 (PIXEL *)(img->data[0] + y * img->linesize[0]), | |
1124 (uint16_t *) buf, img->w, img_spp); | |
1125 | |
1126 if (img_alpha) | |
1127 { | |
1128 gray16_to_gray(&cvt, | |
1129 (PIXEL *)(img->data[1] + y * img->linesize[1]), | |
1130 ((uint16_t *) buf) + 1, img->w, 2); | |
1131 } | |
1132 } | |
1133 else | |
1134 { | |
1135 luma8_to_gray(&cvt, | |
1136 (PIXEL *)(img->data[0] + y * img->linesize[0]), | |
1137 (uint8_t *) buf, img->w, img_spp); | |
1138 | |
1139 if (img_alpha) | |
1140 { | |
1141 gray8_to_gray(&cvt, | |
1142 (PIXEL *)(img->data[1] + y * img->linesize[1]), | |
1143 ((uint8_t *) buf) + 1, img->w, 2); | |
1108 } | 1144 } |
1109 } | 1145 } |
1110 break; | 1146 break; |
1111 } | 1147 } |
1112 } | 1148 } |