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
gif_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/gif/gif_decoder.h"
8
9#include "core/fxcodec/cfx_codec_memory.h"
10#include "core/fxcodec/gif/cfx_gifcontext.h"
11#include "core/fxge/dib/fx_dib.h"
12
13namespace fxcodec {
14
15// static
16std::unique_ptr<ProgressiveDecoderIface::Context> GifDecoder::StartDecode(
17 Delegate* pDelegate) {
18 return std::make_unique<CFX_GifContext>(pDelegate);
19}
20
21// static
24 int* width,
25 int* height,
26 int* pal_num,
27 CFX_GifPalette** pal_pp,
28 int* bg_index) {
29 auto* context = static_cast<CFX_GifContext*>(pContext);
30 Status ret = context->ReadHeader();
31 if (ret != Status::kSuccess)
32 return ret;
33
34 *width = context->width_;
35 *height = context->height_;
36 *pal_num = (2 << context->global_palette_exp_);
37 *pal_pp = context->global_palette_.empty() ? nullptr
38 : context->global_palette_.data();
39 *bg_index = context->bc_index_;
40 return Status::kSuccess;
41}
42
43// static
44std::pair<GifDecoder::Status, size_t> GifDecoder::LoadFrameInfo(
46 auto* context = static_cast<CFX_GifContext*>(pContext);
47 Status ret = context->GetFrame();
48 if (ret != Status::kSuccess)
49 return {ret, 0};
50 return {Status::kSuccess, context->GetFrameNum()};
51}
52
53// static
56 size_t frame_num) {
57 return static_cast<CFX_GifContext*>(pContext)->LoadFrame(frame_num);
58}
59
60// static
65
66// static
68 RetainPtr<CFX_CodecMemory> codec_memory) {
69 auto* ctx = static_cast<CFX_GifContext*>(pContext);
70 ctx->SetInputBuffer(std::move(codec_memory));
71 return true;
72}
73
74} // namespace fxcodec
GifDecoder::Status GetFrame()
void SetInputBuffer(RetainPtr< CFX_CodecMemory > codec_memory)
uint32_t GetAvailInput() const
GifDecoder::Status ReadHeader()
static FX_FILESIZE GetAvailInput(ProgressiveDecoderIface::Context *context)
static bool Input(ProgressiveDecoderIface::Context *context, RetainPtr< CFX_CodecMemory > codec_memory)
static Status ReadHeader(ProgressiveDecoderIface::Context *context, int *width, int *height, int *pal_num, CFX_GifPalette **pal_pp, int *bg_index)
#define FX_FILESIZE
Definition fx_types.h:19