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/fx_codec.h" | 8 #include "core/fxcodec/fx_codec.h" |
9 #include "core/fxcodec/lbmp/fx_bmp.h" | 9 #include "core/fxcodec/lbmp/fx_bmp.h" |
10 #include "core/fxge/fx_dib.h" | 10 #include "core/fxge/fx_dib.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1); | 29 FXSYS_strncpy((char*)bmp_ptr->err_ptr, err_msg, BMP_MAX_ERROR_SIZE - 1); |
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 bool bmp_get_data_position(bmp_decompress_struct_p bmp_ptr, |
40 uint32_t 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 | 45 |
46 FXBMP_Context* CCodec_BmpModule::Start(void* pModule) { | 46 FXBMP_Context* CCodec_BmpModule::Start(void* pModule) { |
47 FXBMP_Context* p = FX_Alloc(FXBMP_Context, 1); | 47 FXBMP_Context* p = FX_Alloc(FXBMP_Context, 1); |
48 if (!p) | 48 if (!p) |
49 return nullptr; | 49 return nullptr; |
50 | 50 |
(...skipping 21 matching lines...) Expand all Loading... |
72 | 72 |
73 void CCodec_BmpModule::Finish(FXBMP_Context* ctx) { | 73 void CCodec_BmpModule::Finish(FXBMP_Context* ctx) { |
74 if (ctx) { | 74 if (ctx) { |
75 bmp_destroy_decompress(&ctx->bmp_ptr); | 75 bmp_destroy_decompress(&ctx->bmp_ptr); |
76 ctx->m_FreeFunc(ctx); | 76 ctx->m_FreeFunc(ctx); |
77 } | 77 } |
78 } | 78 } |
79 int32_t CCodec_BmpModule::ReadHeader(FXBMP_Context* ctx, | 79 int32_t CCodec_BmpModule::ReadHeader(FXBMP_Context* ctx, |
80 int32_t* width, | 80 int32_t* width, |
81 int32_t* height, | 81 int32_t* height, |
82 FX_BOOL* tb_flag, | 82 bool* tb_flag, |
83 int32_t* components, | 83 int32_t* components, |
84 int32_t* pal_num, | 84 int32_t* pal_num, |
85 uint32_t** pal_pp, | 85 uint32_t** pal_pp, |
86 CFX_DIBAttribute* pAttribute) { | 86 CFX_DIBAttribute* pAttribute) { |
87 if (setjmp(ctx->bmp_ptr->jmpbuf)) { | 87 if (setjmp(ctx->bmp_ptr->jmpbuf)) { |
88 return 0; | 88 return 0; |
89 } | 89 } |
90 int32_t ret = bmp_read_header(ctx->bmp_ptr); | 90 int32_t ret = bmp_read_header(ctx->bmp_ptr); |
91 if (ret != 1) { | 91 if (ret != 1) { |
92 return ret; | 92 return ret; |
(...skipping 22 matching lines...) Expand all Loading... |
115 uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx, | 115 uint32_t CCodec_BmpModule::GetAvailInput(FXBMP_Context* ctx, |
116 uint8_t** avail_buf_ptr) { | 116 uint8_t** avail_buf_ptr) { |
117 return bmp_get_avail_input(ctx->bmp_ptr, avail_buf_ptr); | 117 return bmp_get_avail_input(ctx->bmp_ptr, avail_buf_ptr); |
118 } | 118 } |
119 | 119 |
120 void CCodec_BmpModule::Input(FXBMP_Context* ctx, | 120 void CCodec_BmpModule::Input(FXBMP_Context* ctx, |
121 const uint8_t* src_buf, | 121 const uint8_t* src_buf, |
122 uint32_t src_size) { | 122 uint32_t src_size) { |
123 bmp_input_buffer(ctx->bmp_ptr, (uint8_t*)src_buf, src_size); | 123 bmp_input_buffer(ctx->bmp_ptr, (uint8_t*)src_buf, src_size); |
124 } | 124 } |
OLD | NEW |