blob: d8ebdd556270078bf1e5a2ca133f8a4ec3041305 [file]
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fxcodec/bmp/bmp_decoder.h"
#include "core/fxcodec/bmp/cfx_bmpcontext.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/check.h"
namespace fxcodec {
// static
ProgressiveDecoderContext::Status BmpDecoder::ReadHeader(
ProgressiveDecoderContext* context,
int32_t* width,
int32_t* height,
bool* tb_flag,
int32_t* components,
pdfium::span<const FX_ARGB>* palette,
CFX_DIBAttribute* pAttribute) {
DCHECK(pAttribute);
auto* ctx = static_cast<CFX_BmpContext*>(context);
ProgressiveDecoderContext::Status status = ctx->bmp_.ReadHeader();
if (status != ProgressiveDecoderContext::Status::kSuccess) {
return status;
}
*width = ctx->bmp_.width();
*height = ctx->bmp_.height();
*tb_flag = ctx->bmp_.img_tb_flag();
*components = ctx->bmp_.components();
*palette = ctx->bmp_.palette();
pAttribute->dpi_unit_ = CFX_DIBAttribute::kResUnitMeter;
pAttribute->x_dpi_ = ctx->bmp_.dpi_x();
pAttribute->y_dpi_ = ctx->bmp_.dpi_y();
return ProgressiveDecoderContext::Status::kSuccess;
}
} // namespace fxcodec