OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/include/fxcodec/fx_codec.h" | 7 #include "core/include/fxcodec/fx_codec.h" |
8 #include "core/include/fxge/fx_dib.h" | 8 #include "core/include/fxge/fx_dib.h" |
9 #include "core/src/fxcodec/codec/fx_codec_progress.h" | 9 #include "core/src/fxcodec/codec/fx_codec_progress.h" |
10 void CFXCODEC_WeightTable::Calc(int dest_len, | 10 void CFXCODEC_WeightTable::Calc(int dest_len, |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( | 1251 FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo( |
1252 IFX_FileRead* pFile, | 1252 IFX_FileRead* pFile, |
1253 FXCODEC_IMAGE_TYPE imageType, | 1253 FXCODEC_IMAGE_TYPE imageType, |
1254 CFX_DIBAttribute* pAttribute) { | 1254 CFX_DIBAttribute* pAttribute) { |
1255 switch (m_status) { | 1255 switch (m_status) { |
1256 case FXCODEC_STATUS_FRAME_READY: | 1256 case FXCODEC_STATUS_FRAME_READY: |
1257 case FXCODEC_STATUS_FRAME_TOBECONTINUE: | 1257 case FXCODEC_STATUS_FRAME_TOBECONTINUE: |
1258 case FXCODEC_STATUS_DECODE_READY: | 1258 case FXCODEC_STATUS_DECODE_READY: |
1259 case FXCODEC_STATUS_DECODE_TOBECONTINUE: | 1259 case FXCODEC_STATUS_DECODE_TOBECONTINUE: |
1260 return FXCODEC_STATUS_ERROR; | 1260 return FXCODEC_STATUS_ERROR; |
1261 default:; | 1261 default: |
| 1262 break; |
1262 } | 1263 } |
1263 if (pFile == NULL) { | 1264 if (pFile == NULL) { |
1264 m_status = FXCODEC_STATUS_ERR_PARAMS; | 1265 m_status = FXCODEC_STATUS_ERR_PARAMS; |
1265 m_pFile = NULL; | 1266 m_pFile = NULL; |
1266 return m_status; | 1267 return m_status; |
1267 } | 1268 } |
1268 m_pFile = pFile; | 1269 m_pFile = pFile; |
1269 m_offSet = 0; | 1270 m_offSet = 0; |
1270 m_SrcWidth = m_SrcHeight = 0; | 1271 m_SrcWidth = m_SrcHeight = 0; |
1271 m_SrcComponents = m_SrcBPC = 0; | 1272 m_SrcComponents = m_SrcBPC = 0; |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 frames = m_FrameNumber; | 1815 frames = m_FrameNumber; |
1815 return m_status = FXCODEC_STATUS_DECODE_READY; | 1816 return m_status = FXCODEC_STATUS_DECODE_READY; |
1816 } | 1817 } |
1817 if (m_pGifContext) { | 1818 if (m_pGifContext) { |
1818 pGifModule->Finish(m_pGifContext); | 1819 pGifModule->Finish(m_pGifContext); |
1819 m_pGifContext = NULL; | 1820 m_pGifContext = NULL; |
1820 } | 1821 } |
1821 return m_status = FXCODEC_STATUS_ERROR; | 1822 return m_status = FXCODEC_STATUS_ERROR; |
1822 } | 1823 } |
1823 } break; | 1824 } break; |
1824 default:; | 1825 default: |
| 1826 break; |
1825 } | 1827 } |
1826 return FXCODEC_STATUS_ERROR; | 1828 return FXCODEC_STATUS_ERROR; |
1827 } | 1829 } |
1828 FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, | 1830 FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, |
1829 int start_x, | 1831 int start_x, |
1830 int start_y, | 1832 int start_y, |
1831 int size_x, | 1833 int size_x, |
1832 int size_y, | 1834 int size_y, |
1833 int32_t frames, | 1835 int32_t frames, |
1834 FX_BOOL bInterpol) { | 1836 FX_BOOL bInterpol) { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2212 pClipBitmap->GetHeight(), FXDIB_Rgb); | 2214 pClipBitmap->GetHeight(), FXDIB_Rgb); |
2213 break; | 2215 break; |
2214 case FXDIB_Rgb32: | 2216 case FXDIB_Rgb32: |
2215 pFormatBitmap = new CFX_DIBitmap; | 2217 pFormatBitmap = new CFX_DIBitmap; |
2216 pFormatBitmap->Create(pClipBitmap->GetWidth(), | 2218 pFormatBitmap->Create(pClipBitmap->GetWidth(), |
2217 pClipBitmap->GetHeight(), FXDIB_Rgb32); | 2219 pClipBitmap->GetHeight(), FXDIB_Rgb32); |
2218 break; | 2220 break; |
2219 case FXDIB_Argb: | 2221 case FXDIB_Argb: |
2220 pFormatBitmap = pClipBitmap; | 2222 pFormatBitmap = pClipBitmap; |
2221 break; | 2223 break; |
2222 default:; | 2224 default: |
| 2225 break; |
2223 } | 2226 } |
2224 switch (m_pDeviceBitmap->GetFormat()) { | 2227 switch (m_pDeviceBitmap->GetFormat()) { |
2225 case FXDIB_8bppRgb: | 2228 case FXDIB_8bppRgb: |
2226 case FXDIB_8bppMask: { | 2229 case FXDIB_8bppMask: { |
2227 for (int32_t row = 0; row < pClipBitmap->GetHeight(); row++) { | 2230 for (int32_t row = 0; row < pClipBitmap->GetHeight(); row++) { |
2228 uint8_t* src_line = (uint8_t*)pClipBitmap->GetScanline(row); | 2231 uint8_t* src_line = (uint8_t*)pClipBitmap->GetScanline(row); |
2229 uint8_t* des_line = (uint8_t*)pFormatBitmap->GetScanline(row); | 2232 uint8_t* des_line = (uint8_t*)pFormatBitmap->GetScanline(row); |
2230 for (int32_t col = 0; col < pClipBitmap->GetWidth(); col++) { | 2233 for (int32_t col = 0; col < pClipBitmap->GetWidth(); col++) { |
2231 uint8_t _a = 255 - src_line[3]; | 2234 uint8_t _a = 255 - src_line[3]; |
2232 uint8_t b = (src_line[0] * src_line[3] + 0xFF * _a) / 255; | 2235 uint8_t b = (src_line[0] * src_line[3] + 0xFF * _a) / 255; |
(...skipping 17 matching lines...) Expand all Loading... |
2250 uint8_t g = (src_line[1] * src_line[3] + 0xFF * _a) / 255; | 2253 uint8_t g = (src_line[1] * src_line[3] + 0xFF * _a) / 255; |
2251 uint8_t r = (src_line[2] * src_line[3] + 0xFF * _a) / 255; | 2254 uint8_t r = (src_line[2] * src_line[3] + 0xFF * _a) / 255; |
2252 *des_line++ = b; | 2255 *des_line++ = b; |
2253 *des_line++ = g; | 2256 *des_line++ = g; |
2254 *des_line++ = r; | 2257 *des_line++ = r; |
2255 des_line += desBpp - 3; | 2258 des_line += desBpp - 3; |
2256 src_line += 4; | 2259 src_line += 4; |
2257 } | 2260 } |
2258 } | 2261 } |
2259 } break; | 2262 } break; |
2260 default:; | 2263 default: |
| 2264 break; |
2261 } | 2265 } |
2262 if (pClipBitmap != pFormatBitmap) { | 2266 if (pClipBitmap != pFormatBitmap) { |
2263 delete pClipBitmap; | 2267 delete pClipBitmap; |
2264 } | 2268 } |
2265 if (pFormatBitmap == NULL) { | 2269 if (pFormatBitmap == NULL) { |
2266 m_pDeviceBitmap = NULL; | 2270 m_pDeviceBitmap = NULL; |
2267 m_pFile = NULL; | 2271 m_pFile = NULL; |
2268 return m_status = FXCODEC_STATUS_ERR_MEMORY; | 2272 return m_status = FXCODEC_STATUS_ERR_MEMORY; |
2269 } | 2273 } |
2270 CFX_DIBitmap* pStrechBitmap = pFormatBitmap->StretchTo( | 2274 CFX_DIBitmap* pStrechBitmap = pFormatBitmap->StretchTo( |
(...skipping 15 matching lines...) Expand all Loading... |
2286 } | 2290 } |
2287 } break; | 2291 } break; |
2288 default: | 2292 default: |
2289 break; | 2293 break; |
2290 } | 2294 } |
2291 return FXCODEC_STATUS_ERROR; | 2295 return FXCODEC_STATUS_ERROR; |
2292 } | 2296 } |
2293 ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { | 2297 ICodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { |
2294 return new CCodec_ProgressiveDecoder(this); | 2298 return new CCodec_ProgressiveDecoder(this); |
2295 } | 2299 } |
OLD | NEW |