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/fxcodec/codec/codec_int.h" | 7 #include "core/fxcodec/codec/codec_int.h" |
8 #include "core/fxcodec/lbmp/fx_bmp.h" | 8 #include "core/fxcodec/lbmp/fx_bmp.h" |
9 #include "core/include/fxcodec/fx_codec.h" | 9 #include "core/include/fxcodec/fx_codec.h" |
10 #include "core/include/fxge/fx_dib.h" | 10 #include "core/include/fxge/fx_dib.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 longjmp(bmp_ptr->jmpbuf, 1); | 30 longjmp(bmp_ptr->jmpbuf, 1); |
31 } | 31 } |
32 static void bmp_read_scanline(bmp_decompress_struct_p bmp_ptr, | 32 static void bmp_read_scanline(bmp_decompress_struct_p bmp_ptr, |
33 int32_t row_num, | 33 int32_t row_num, |
34 uint8_t* row_buf) { | 34 uint8_t* row_buf) { |
35 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; | 35 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; |
36 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; | 36 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; |
37 pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); | 37 pModule->ReadScanlineCallback(p->child_ptr, row_num, row_buf); |
38 } | 38 } |
39 static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, | 39 static FX_BOOL bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, |
40 FX_DWORD rcd_pos) { | 40 uint32_t rcd_pos) { |
41 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; | 41 FXBMP_Context* p = (FXBMP_Context*)bmp_ptr->context_ptr; |
42 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; | 42 CCodec_BmpModule* pModule = (CCodec_BmpModule*)p->parent_ptr; |
43 return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); | 43 return pModule->InputImagePositionBufCallback(p->child_ptr, rcd_pos); |
44 } | 44 } |
45 void* CCodec_BmpModule::Start(void* pModule) { | 45 void* CCodec_BmpModule::Start(void* pModule) { |
46 FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(uint8_t, sizeof(FXBMP_Context)); | 46 FXBMP_Context* p = (FXBMP_Context*)FX_Alloc(uint8_t, sizeof(FXBMP_Context)); |
47 if (p == NULL) { | 47 if (p == NULL) { |
48 return NULL; | 48 return NULL; |
49 } | 49 } |
50 FXSYS_memset(p, 0, sizeof(FXBMP_Context)); | 50 FXSYS_memset(p, 0, sizeof(FXBMP_Context)); |
(...skipping 23 matching lines...) Expand all Loading... |
74 bmp_destroy_decompress(&p->bmp_ptr); | 74 bmp_destroy_decompress(&p->bmp_ptr); |
75 p->m_FreeFunc(p); | 75 p->m_FreeFunc(p); |
76 } | 76 } |
77 } | 77 } |
78 int32_t CCodec_BmpModule::ReadHeader(void* pContext, | 78 int32_t CCodec_BmpModule::ReadHeader(void* pContext, |
79 int32_t* width, | 79 int32_t* width, |
80 int32_t* height, | 80 int32_t* height, |
81 FX_BOOL* tb_flag, | 81 FX_BOOL* tb_flag, |
82 int32_t* components, | 82 int32_t* components, |
83 int32_t* pal_num, | 83 int32_t* pal_num, |
84 FX_DWORD** pal_pp, | 84 uint32_t** pal_pp, |
85 CFX_DIBAttribute* pAttribute) { | 85 CFX_DIBAttribute* pAttribute) { |
86 FXBMP_Context* p = (FXBMP_Context*)pContext; | 86 FXBMP_Context* p = (FXBMP_Context*)pContext; |
87 if (setjmp(p->bmp_ptr->jmpbuf)) { | 87 if (setjmp(p->bmp_ptr->jmpbuf)) { |
88 return 0; | 88 return 0; |
89 } | 89 } |
90 int32_t ret = bmp_read_header(p->bmp_ptr); | 90 int32_t ret = bmp_read_header(p->bmp_ptr); |
91 if (ret != 1) { | 91 if (ret != 1) { |
92 return ret; | 92 return ret; |
93 } | 93 } |
94 *width = p->bmp_ptr->width; | 94 *width = p->bmp_ptr->width; |
(...skipping 10 matching lines...) Expand all Loading... |
105 } | 105 } |
106 return 1; | 106 return 1; |
107 } | 107 } |
108 int32_t CCodec_BmpModule::LoadImage(void* pContext) { | 108 int32_t CCodec_BmpModule::LoadImage(void* pContext) { |
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, | 115 uint32_t CCodec_BmpModule::GetAvailInput(void* pContext, |
116 uint8_t** avial_buf_ptr) { | 116 uint8_t** avial_buf_ptr) { |
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, | 120 void CCodec_BmpModule::Input(void* pContext, |
121 const uint8_t* src_buf, | 121 const uint8_t* src_buf, |
122 FX_DWORD src_size) { | 122 uint32_t src_size) { |
123 FXBMP_Context* p = (FXBMP_Context*)pContext; | 123 FXBMP_Context* p = (FXBMP_Context*)pContext; |
124 bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size); | 124 bmp_input_buffer(p->bmp_ptr, (uint8_t*)src_buf, src_size); |
125 } | 125 } |
OLD | NEW |