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/fxcrt/check.h"
16
17namespace fxcodec {
18
19// static
20std::unique_ptr<ProgressiveDecoderIface::Context> BmpDecoder::StartDecode(
21 Delegate* pDelegate) {
22 return std::make_unique<CFX_BmpContext>(pDelegate);
23}
24
25// static
28 int32_t* width,
29 int32_t* height,
30 bool* tb_flag,
31 int32_t* components,
32 pdfium::span<const FX_ARGB>* palette,
33 CFX_DIBAttribute* pAttribute) {
34 DCHECK(pAttribute);
35
36 auto* ctx = static_cast<CFX_BmpContext*>(pContext);
37 Status status = ctx->m_Bmp.ReadHeader();
38 if (status != Status::kSuccess)
39 return status;
40
41 *width = ctx->m_Bmp.width();
42 *height = ctx->m_Bmp.height();
43 *tb_flag = ctx->m_Bmp.img_tb_flag();
44 *components = ctx->m_Bmp.components();
45 *palette = ctx->m_Bmp.palette();
46 pAttribute->m_wDPIUnit = CFX_DIBAttribute::kResUnitMeter;
47 pAttribute->m_nXDPI = ctx->m_Bmp.dpi_x();
48 pAttribute->m_nYDPI = ctx->m_Bmp.dpi_y();
49 return Status::kSuccess;
50}
51
52// static
55 return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.DecodeImage();
56}
57
58// static
61 return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.GetAvailInput();
62}
63
64// static
66 RetainPtr<CFX_CodecMemory> codec_memory) {
67 auto* ctx = static_cast<CFX_BmpContext*>(pContext);
68 ctx->m_Bmp.SetInputBuffer(std::move(codec_memory));
69 return true;
70}
71
72} // namespace fxcodec
#define DCHECK
Definition check.h:33
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