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
cfx_bitmapstorer.cpp
Go to the documentation of this file.
1// Copyright 2017 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/fxge/dib/cfx_bitmapstorer.h"
8
9#include <string.h>
10
11#include <utility>
12
13#include "core/fxcrt/span_util.h"
14#include "core/fxge/dib/cfx_dibitmap.h"
15#include "third_party/base/check_op.h"
16
17CFX_BitmapStorer::CFX_BitmapStorer() = default;
18
19CFX_BitmapStorer::~CFX_BitmapStorer() = default;
20
21RetainPtr<CFX_DIBitmap> CFX_BitmapStorer::Detach() {
22 return std::move(m_pBitmap);
23}
24
25void CFX_BitmapStorer::Replace(RetainPtr<CFX_DIBitmap>&& pBitmap) {
26 m_pBitmap = std::move(pBitmap);
27}
28
29void CFX_BitmapStorer::ComposeScanline(int line,
30 pdfium::span<const uint8_t> scanline) {
31 pdfium::span<uint8_t> dest_buf = m_pBitmap->GetWritableScanline(line);
32 if (!dest_buf.empty())
33 fxcrt::spancpy(dest_buf, scanline);
34}
35
36bool CFX_BitmapStorer::SetInfo(int width,
37 int height,
38 FXDIB_Format src_format,
39 DataVector<uint32_t> src_palette) {
40 DCHECK_NE(src_format, FXDIB_Format::k1bppMask);
41 DCHECK_NE(src_format, FXDIB_Format::k1bppRgb);
42 auto pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
43 if (!pBitmap->Create(width, height, src_format))
44 return false;
45
46 if (!src_palette.empty()) {
47 pBitmap->TakePalette(std::move(src_palette));
48 }
49
50 m_pBitmap = std::move(pBitmap);
51 return true;
52}
void ComposeScanline(int line, pdfium::span< const uint8_t > scanline) override
~CFX_BitmapStorer() override
void Replace(RetainPtr< CFX_DIBitmap > &&pBitmap)
RetainPtr< CFX_DIBitmap > Detach()
bool SetInfo(int width, int height, FXDIB_Format src_format, DataVector< uint32_t > src_palette) override
FXDIB_Format
Definition fx_dib.h:19