Kiwano Engine v1.3.x
GifImage.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/core/Time.h>
23#include <kiwano/render/Texture.h>
24
25namespace kiwano
26{
27
37class KGE_API GifImage : public NativeObject
38{
39public:
40 GifImage();
41
44 GifImage(StringView file_path);
45
48 GifImage(const Resource& res);
49
52 bool Load(StringView file_path);
53
56 bool Load(const Resource& res);
57
60 uint32_t GetWidthInPixels() const;
61
64 uint32_t GetHeightInPixels() const;
65
68 PixelSize GetSizeInPixels() const;
69
72 uint32_t GetFramesCount() const;
73
74public:
77 enum class DisposalType
78 {
79 Unknown,
80 None,
81 Background,
82 Previous
83 };
84
87 struct Frame
88 {
93
94 Frame();
95 };
96
100 Frame GetFrame(uint32_t index);
101
102private:
103 bool GetGlobalMetadata();
104
105private:
106 uint32_t frames_count_;
107 PixelSize size_in_pixels_;
108};
109
112inline GifImage::Frame::Frame()
113 : disposal_type(DisposalType::Unknown)
114{
115}
116
117inline uint32_t GifImage::GetWidthInPixels() const
118{
119 return size_in_pixels_.x;
120}
121
122inline uint32_t GifImage::GetHeightInPixels() const
123{
124 return size_in_pixels_.y;
125}
126
128{
129 return size_in_pixels_;
130}
131
132inline uint32_t GifImage::GetFramesCount() const
133{
134 return frames_count_;
135}
136
137} // namespace kiwano
GIF图像
Definition: GifImage.h:38
uint32_t GetFramesCount() const
获取帧数量
Definition: GifImage.h:132
PixelSize GetSizeInPixels() const
获取像素大小
Definition: GifImage.h:127
uint32_t GetWidthInPixels() const
获取像素宽度
Definition: GifImage.h:117
DisposalType
GIF帧的处置方式
Definition: GifImage.h:78
uint32_t GetHeightInPixels() const
获取像素高度
Definition: GifImage.h:122
含有本地指针的对象
Definition: NativeObject.hpp:32
引用计数智能指针
Definition: RefBasePtr.hpp:35
资源
Definition: Resource.h:41
@ None
不启用抗锯齿
时间段
Definition: Duration.h:48
GIF帧
Definition: GifImage.h:88
DisposalType disposal_type
处置方式
Definition: GifImage.h:92
Duration delay
帧延迟
Definition: GifImage.h:89
Rect rect
绘制区域
Definition: GifImage.h:91
RefPtr< Texture > texture
帧图像
Definition: GifImage.h:90