| 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 "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 #include "../../../include/fxge/fx_dib.h" | 8 #include "../../../include/fxge/fx_dib.h" |
| 9 #include "codec_int.h" | 9 #include "codec_int.h" |
| 10 #include "../lbmp/fx_bmp.h" | 10 #include "../lbmp/fx_bmp.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 if(p != NULL) { | 26 if(p != NULL) { |
| 27 FX_Free(p); | 27 FX_Free(p); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 }; | 30 }; |
| 31 static void _bmp_error_data(bmp_decompress_struct_p bmp_ptr, FX_LPCSTR err_msg) | 31 static void _bmp_error_data(bmp_decompress_struct_p bmp_ptr, FX_LPCSTR err_msg) |
| 32 { | 32 { |
| 33 FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1); | 33 FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1); |
| 34 longjmp(bmp_ptr->jmpbuf, 1); | 34 longjmp(bmp_ptr->jmpbuf, 1); |
| 35 } | 35 } |
| 36 static void _bmp_read_scanline(bmp_decompress_struct_p bmp_ptr, FX_INT32 row_num
, FX_LPBYTE row_buf) | 36 static void _bmp_read_scanline(bmp_decompress_struct_p bmp_ptr, int32_t row_num,
FX_LPBYTE row_buf) |
| 37 { | 37 { |
| 38 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; | 38 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; |
| 39 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; | 39 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; |
| 40 pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); | 40 pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); |
| 41 } | 41 } |
| 42 static FX_BOOL _bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, FX_DWORD
rcd_pos) | 42 static FX_BOOL _bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, FX_DWORD
rcd_pos) |
| 43 { | 43 { |
| 44 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; | 44 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; |
| 45 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; | 45 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; |
| 46 return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); | 46 return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); |
| 47 } | 47 } |
| 48 void* CCodec_BmpModule::Start(void* pModule) | 48 void* CCodec_BmpModule::Start(void* pModule) |
| 49 { | 49 { |
| 50 FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(FX_BYTE, sizeof(FXBMP_Context)); | 50 FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(uint8_t, sizeof(FXBMP_Context)); |
| 51 if (p == NULL) { | 51 if (p == NULL) { |
| 52 return NULL; | 52 return NULL; |
| 53 } | 53 } |
| 54 FXSYS_memset32(p, 0, sizeof(FXBMP_Context)); | 54 FXSYS_memset32(p, 0, sizeof(FXBMP_Context)); |
| 55 if(p == NULL) { | 55 if(p == NULL) { |
| 56 return NULL; | 56 return NULL; |
| 57 } | 57 } |
| 58 p->m_AllocFunc = _bmp_alloc_func; | 58 p->m_AllocFunc = _bmp_alloc_func; |
| 59 p->m_FreeFunc = _bmp_free_func; | 59 p->m_FreeFunc = _bmp_free_func; |
| 60 p->bmp_ptr = NULL; | 60 p->bmp_ptr = NULL; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 return p; | 73 return p; |
| 74 } | 74 } |
| 75 void CCodec_BmpModule::Finish(void* pContext) | 75 void CCodec_BmpModule::Finish(void* pContext) |
| 76 { | 76 { |
| 77 FXBMP_Context* p = (FXBMP_Context*)pContext; | 77 FXBMP_Context* p = (FXBMP_Context*)pContext; |
| 78 if(p != NULL) { | 78 if(p != NULL) { |
| 79 _bmp_destroy_decompress(&p->bmp_ptr); | 79 _bmp_destroy_decompress(&p->bmp_ptr); |
| 80 p->m_FreeFunc(p); | 80 p->m_FreeFunc(p); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 FX_INT32 CCodec_BmpModule::ReadHeader(void* pContext, FX_INT32* width, FX_INT32*
height, FX_BOOL* tb_flag, FX_INT32* components, FX_INT32* pal_num, FX_DWORD** p
al_pp, CFX_DIBAttribute* pAttribute) | 83 int32_t CCodec_BmpModule::ReadHeader(void* pContext, int32_t* width, int32_t* he
ight, FX_BOOL* tb_flag, int32_t* components, int32_t* pal_num, FX_DWORD** pal_pp
, CFX_DIBAttribute* pAttribute) |
| 84 { | 84 { |
| 85 FXBMP_Context* p = (FXBMP_Context*)pContext; | 85 FXBMP_Context* p = (FXBMP_Context*)pContext; |
| 86 if(setjmp(p->bmp_ptr->jmpbuf)) { | 86 if(setjmp(p->bmp_ptr->jmpbuf)) { |
| 87 return 0; | 87 return 0; |
| 88 } | 88 } |
| 89 FX_INT32 ret = _bmp_read_header(p->bmp_ptr); | 89 int32_t ret = _bmp_read_header(p->bmp_ptr); |
| 90 if (ret != 1) { | 90 if (ret != 1) { |
| 91 return ret; | 91 return ret; |
| 92 } | 92 } |
| 93 *width = p->bmp_ptr->width; | 93 *width = p->bmp_ptr->width; |
| 94 *height = p->bmp_ptr->height; | 94 *height = p->bmp_ptr->height; |
| 95 *tb_flag = p->bmp_ptr->imgTB_flag; | 95 *tb_flag = p->bmp_ptr->imgTB_flag; |
| 96 *components = p->bmp_ptr->components; | 96 *components = p->bmp_ptr->components; |
| 97 *pal_num = p->bmp_ptr->pal_num; | 97 *pal_num = p->bmp_ptr->pal_num; |
| 98 *pal_pp = p->bmp_ptr->pal_ptr; | 98 *pal_pp = p->bmp_ptr->pal_ptr; |
| 99 if (pAttribute) { | 99 if (pAttribute) { |
| 100 pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER; | 100 pAttribute->m_wDPIUnit = FXCODEC_RESUNIT_METER; |
| 101 pAttribute->m_nXDPI = p->bmp_ptr->dpi_x; | 101 pAttribute->m_nXDPI = p->bmp_ptr->dpi_x; |
| 102 pAttribute->m_nYDPI = p->bmp_ptr->dpi_y; | 102 pAttribute->m_nYDPI = p->bmp_ptr->dpi_y; |
| 103 pAttribute->m_nBmpCompressType = p->bmp_ptr->compress_flag; | 103 pAttribute->m_nBmpCompressType = p->bmp_ptr->compress_flag; |
| 104 } | 104 } |
| 105 return 1; | 105 return 1; |
| 106 } | 106 } |
| 107 FX_INT32 CCodec_BmpModule::LoadImage(void* pContext) | 107 int32_t CCodec_BmpModule::LoadImage(void* pContext) |
| 108 { | 108 { |
| 109 FXBMP_Context* p = (FXBMP_Context*)pContext; | 109 FXBMP_Context* p = (FXBMP_Context*)pContext; |
| 110 if(setjmp(p->bmp_ptr->jmpbuf)) { | 110 if(setjmp(p->bmp_ptr->jmpbuf)) { |
| 111 return 0; | 111 return 0; |
| 112 } | 112 } |
| 113 return _bmp_decode_image(p->bmp_ptr); | 113 return _bmp_decode_image(p->bmp_ptr); |
| 114 } | 114 } |
| 115 FX_DWORD CCodec_BmpModule::GetAvailInput(void* pContext, FX_LPBYTE* avial_buf_pt
r) | 115 FX_DWORD CCodec_BmpModule::GetAvailInput(void* pContext, FX_LPBYTE* avial_buf_pt
r) |
| 116 { | 116 { |
| 117 FXBMP_Context* p = (FXBMP_Context*)pContext; | 117 FXBMP_Context* p = (FXBMP_Context*)pContext; |
| 118 return _bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr); | 118 return _bmp_get_avail_input(p->bmp_ptr, avial_buf_ptr); |
| 119 } | 119 } |
| 120 void CCodec_BmpModule::Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_si
ze) | 120 void CCodec_BmpModule::Input(void* pContext, FX_LPCBYTE src_buf, FX_DWORD src_si
ze) |
| 121 { | 121 { |
| 122 FXBMP_Context* p = (FXBMP_Context*)pContext; | 122 FXBMP_Context* p = (FXBMP_Context*)pContext; |
| 123 _bmp_input_buffer(p->bmp_ptr, (FX_LPBYTE)src_buf, src_size); | 123 _bmp_input_buffer(p->bmp_ptr, (FX_LPBYTE)src_buf, src_size); |
| 124 } | 124 } |
| OLD | NEW |