Kiwano Engine v1.2.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{
27KGE_DECLARE_SMART_PTR(GifImage);
28
38class KGE_API GifImage : public NativeObject
39{
40public:
41 GifImage();
42
45 GifImage(const String& file_path);
46
49 GifImage(const Resource& res);
50
53 bool Load(const String& file_path);
54
57 bool Load(const Resource& res);
58
61 uint32_t GetWidthInPixels() const;
62
65 uint32_t GetHeightInPixels() const;
66
69 PixelSize GetSizeInPixels() const;
70
73 uint32_t GetFramesCount() const;
74
75public:
78 enum class DisposalType
79 {
80 Unknown,
81 None,
82 Background,
83 Previous
84 };
85
88 struct Frame
89 {
91 TexturePtr texture;
94
95 Frame();
96 };
97
101 Frame GetFrame(uint32_t index);
102
103private:
104 bool GetGlobalMetadata();
105
106private:
107 uint32_t frames_count_;
108 PixelSize size_in_pixels_;
109};
110
113inline GifImage::Frame::Frame()
114 : disposal_type(DisposalType::Unknown)
115{
116}
117
118inline uint32_t GifImage::GetWidthInPixels() const
119{
120 return size_in_pixels_.x;
121}
122
123inline uint32_t GifImage::GetHeightInPixels() const
124{
125 return size_in_pixels_.y;
126}
127
129{
130 return size_in_pixels_;
131}
132
133inline uint32_t GifImage::GetFramesCount() const
134{
135 return frames_count_;
136}
137
138} // namespace kiwano
GIF图像
Definition: GifImage.h:39
uint32_t GetFramesCount() const
获取帧数量
Definition: GifImage.h:133
PixelSize GetSizeInPixels() const
获取像素大小
Definition: GifImage.h:128
uint32_t GetWidthInPixels() const
获取像素宽度
Definition: GifImage.h:118
DisposalType
GIF帧的处置方式
Definition: GifImage.h:79
uint32_t GetHeightInPixels() const
获取像素高度
Definition: GifImage.h:123
含有本地指针的对象
Definition: NativeObject.hpp:34
资源
Definition: Resource.h:41
@ None
不启用抗锯齿
时间段
Definition: Duration.h:48
GIF帧
Definition: GifImage.h:89
DisposalType disposal_type
处置方式
Definition: GifImage.h:93
Duration delay
帧延迟
Definition: GifImage.h:90
Rect rect
绘制区域
Definition: GifImage.h:92
TexturePtr texture
帧图像
Definition: GifImage.h:91