| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C)2009-2011 D. R. Commander. All Rights Reserved. | 2 * Copyright (C)2009-2011 D. R. Commander. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
| 6 * | 6 * |
| 7 * - Redistributions of source code must retain the above copyright notice, | 7 * - Redistributions of source code must retain the above copyright notice, |
| 8 * this list of conditions and the following disclaimer. | 8 * this list of conditions and the following disclaimer. |
| 9 * - Redistributions in binary form must reproduce the above copyright notice, | 9 * - Redistributions in binary form must reproduce the above copyright notice, |
| 10 * this list of conditions and the following disclaimer in the documentation | 10 * this list of conditions and the following disclaimer in the documentation |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 switch(pixelFormat) | 140 switch(pixelFormat) |
| 141 { | 141 { |
| 142 case TJPF_GRAY: | 142 case TJPF_GRAY: |
| 143 cinfo->in_color_space=JCS_GRAYSCALE; break; | 143 cinfo->in_color_space=JCS_GRAYSCALE; break; |
| 144 #if JCS_EXTENSIONS==1 | 144 #if JCS_EXTENSIONS==1 |
| 145 case TJPF_RGB: | 145 case TJPF_RGB: |
| 146 cinfo->in_color_space=JCS_EXT_RGB; break; | 146 cinfo->in_color_space=JCS_EXT_RGB; break; |
| 147 case TJPF_BGR: | 147 case TJPF_BGR: |
| 148 cinfo->in_color_space=JCS_EXT_BGR; break; | 148 cinfo->in_color_space=JCS_EXT_BGR; break; |
| 149 case TJPF_RGBX: | 149 case TJPF_RGBX: |
| 150 case TJPF_RGBA: |
| 150 cinfo->in_color_space=JCS_EXT_RGBX; break; | 151 cinfo->in_color_space=JCS_EXT_RGBX; break; |
| 151 case TJPF_BGRX: | 152 case TJPF_BGRX: |
| 153 case TJPF_BGRA: |
| 152 cinfo->in_color_space=JCS_EXT_BGRX; break; | 154 cinfo->in_color_space=JCS_EXT_BGRX; break; |
| 153 case TJPF_XRGB: | 155 case TJPF_XRGB: |
| 156 case TJPF_ARGB: |
| 154 cinfo->in_color_space=JCS_EXT_XRGB; break; | 157 cinfo->in_color_space=JCS_EXT_XRGB; break; |
| 155 case TJPF_XBGR: | 158 case TJPF_XBGR: |
| 159 case TJPF_ABGR: |
| 156 cinfo->in_color_space=JCS_EXT_XBGR; break; | 160 cinfo->in_color_space=JCS_EXT_XBGR; break; |
| 157 #else | 161 #else |
| 158 case TJPF_RGB: | 162 case TJPF_RGB: |
| 159 if(RGB_RED==0 && RGB_GREEN==1 && RGB_BLUE==2 && RGB_PIXE
LSIZE==3) | 163 if(RGB_RED==0 && RGB_GREEN==1 && RGB_BLUE==2 && RGB_PIXE
LSIZE==3) |
| 160 { | 164 { |
| 161 cinfo->in_color_space=JCS_RGB; break; | 165 cinfo->in_color_space=JCS_RGB; break; |
| 162 } | 166 } |
| 163 default: | 167 default: |
| 164 _throw("Unsupported pixel format"); | 168 _throw("Unsupported pixel format"); |
| 165 #endif | 169 #endif |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 case TJPF_BGR: | 210 case TJPF_BGR: |
| 207 dinfo->out_color_space=JCS_EXT_BGR; break; | 211 dinfo->out_color_space=JCS_EXT_BGR; break; |
| 208 case TJPF_RGBX: | 212 case TJPF_RGBX: |
| 209 dinfo->out_color_space=JCS_EXT_RGBX; break; | 213 dinfo->out_color_space=JCS_EXT_RGBX; break; |
| 210 case TJPF_BGRX: | 214 case TJPF_BGRX: |
| 211 dinfo->out_color_space=JCS_EXT_BGRX; break; | 215 dinfo->out_color_space=JCS_EXT_BGRX; break; |
| 212 case TJPF_XRGB: | 216 case TJPF_XRGB: |
| 213 dinfo->out_color_space=JCS_EXT_XRGB; break; | 217 dinfo->out_color_space=JCS_EXT_XRGB; break; |
| 214 case TJPF_XBGR: | 218 case TJPF_XBGR: |
| 215 dinfo->out_color_space=JCS_EXT_XBGR; break; | 219 dinfo->out_color_space=JCS_EXT_XBGR; break; |
| 220 #if JCS_ALPHA_EXTENSIONS==1 |
| 221 case TJPF_RGBA: |
| 222 dinfo->out_color_space=JCS_EXT_RGBA; break; |
| 223 case TJPF_BGRA: |
| 224 dinfo->out_color_space=JCS_EXT_BGRA; break; |
| 225 case TJPF_ARGB: |
| 226 dinfo->out_color_space=JCS_EXT_ARGB; break; |
| 227 case TJPF_ABGR: |
| 228 dinfo->out_color_space=JCS_EXT_ABGR; break; |
| 229 #endif |
| 216 #else | 230 #else |
| 217 case TJPF_RGB: | 231 case TJPF_RGB: |
| 218 if(RGB_RED==0 && RGB_GREEN==1 && RGB_BLUE==2 && RGB_PIXE
LSIZE==3) | 232 if(RGB_RED==0 && RGB_GREEN==1 && RGB_BLUE==2 && RGB_PIXE
LSIZE==3) |
| 219 { | 233 { |
| 220 dinfo->out_color_space=JCS_RGB; break; | 234 dinfo->out_color_space=JCS_RGB; break; |
| 221 } | 235 } |
| 236 #endif |
| 222 default: | 237 default: |
| 223 _throw("Unsupported pixel format"); | 238 _throw("Unsupported pixel format"); |
| 224 #endif | |
| 225 } | 239 } |
| 226 | 240 |
| 227 #if JCS_EXTENSIONS!=1 | |
| 228 bailout: | 241 bailout: |
| 229 #endif | |
| 230 return retval; | 242 return retval; |
| 231 } | 243 } |
| 232 | 244 |
| 233 | 245 |
| 234 static int getSubsamp(j_decompress_ptr dinfo) | 246 static int getSubsamp(j_decompress_ptr dinfo) |
| 235 { | 247 { |
| 236 int retval=-1, i, k; | 248 int retval=-1, i, k; |
| 237 for(i=0; i<NUMSUBOPT; i++) | 249 for(i=0; i<NUMSUBOPT; i++) |
| 238 { | 250 { |
| 239 if(dinfo->num_components==pixelsize[i]) | 251 if(dinfo->num_components==pixelsize[i]) |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 } | 1092 } |
| 1081 | 1093 |
| 1082 jpeg_finish_decompress(dinfo); | 1094 jpeg_finish_decompress(dinfo); |
| 1083 | 1095 |
| 1084 bailout: | 1096 bailout: |
| 1085 if(cinfo->global_state>CSTATE_START) jpeg_abort_compress(cinfo); | 1097 if(cinfo->global_state>CSTATE_START) jpeg_abort_compress(cinfo); |
| 1086 if(dinfo->global_state>DSTATE_START) jpeg_abort_decompress(dinfo); | 1098 if(dinfo->global_state>DSTATE_START) jpeg_abort_decompress(dinfo); |
| 1087 if(xinfo) free(xinfo); | 1099 if(xinfo) free(xinfo); |
| 1088 return retval; | 1100 return retval; |
| 1089 } | 1101 } |
| OLD | NEW |