Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
bmp_decoder.cpp
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fxcodec/bmp/bmp_decoder.h"
8
9#include <utility>
10
11#include "core/fxcodec/bmp/cfx_bmpcontext.h"
12#include "core/fxcodec/cfx_codec_memory.h"
13#include "core/fxcodec/fx_codec.h"
14#include "core/fxcodec/fx_codec_def.h"
15#include "core/fxge/dib/fx_dib.h"
16#include "third_party/base/check.h"
17
18namespace fxcodec {
19
20// static
21std::unique_ptr<ProgressiveDecoderIface::Context> BmpDecoder::StartDecode(
22 Delegate* pDelegate) {
23 return std::make_unique<CFX_BmpContext>(pDelegate);
24}
25
26// static
29 int32_t* width,
30 int32_t* height,
31 bool* tb_flag,
32 int32_t* components,
33 int32_t* pal_num,
34 const std::vector<uint32_t>** palette,
35 CFX_DIBAttribute* pAttribute) {
36 DCHECK(pAttribute);
37
38 auto* ctx = static_cast<CFX_BmpContext*>(pContext);
39 Status status = ctx->m_Bmp.ReadHeader();
40 if (status != Status::kSuccess)
41 return status;
42
43 *width = ctx->m_Bmp.width();
44 *height = ctx->m_Bmp.height();
45 *tb_flag = ctx->m_Bmp.img_tb_flag();
46 *components = ctx->m_Bmp.components();
47 *pal_num = ctx->m_Bmp.pal_num();
48 *palette = ctx->m_Bmp.palette();
49 pAttribute->m_wDPIUnit = CFX_DIBAttribute::kResUnitMeter;
50 pAttribute->m_nXDPI = ctx->m_Bmp.dpi_x();
51 pAttribute->m_nYDPI = ctx->m_Bmp.dpi_y();
52 return Status::kSuccess;
53}
54
55// static
58 return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.DecodeImage();
59}
60
61// static
64 return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.GetAvailInput();
65}
66
67// static
69 RetainPtr<CFX_CodecMemory> codec_memory) {
70 auto* ctx = static_cast<CFX_BmpContext*>(pContext);
71 ctx->m_Bmp.SetInputBuffer(std::move(codec_memory));
72 return true;
73}
74
75} // namespace fxcodec
static bool Input(ProgressiveDecoderIface::Context *pContext, RetainPtr< CFX_CodecMemory > codec_memory)
static Status LoadImage(ProgressiveDecoderIface::Context *pContext)
static FX_FILESIZE GetAvailInput(ProgressiveDecoderIface::Context *pContext)
#define FX_FILESIZE
Definition fx_types.h:19