Client Upload Part 2

RD Core / Commit #5

Commit Client Upload Part 2

Alex Alex committed 19/10/2026 00:06 main Patch
1,244 files +271,215 -0
A RD_Client/src/framework/core/resourcemanager.h +127-0 View file
@@ -0,0 +1,127 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#ifndef RESOURCES_H
24+#define RESOURCES_H
25+
26+#include "declarations.h"
27+
28+// @bindsingleton g_resources
29+class ResourceManager
30+{
31+public:
32+ // @dontbind
33+ void init(const char *argv0);
34+ // @dontbind
35+ void terminate();
36+
37+ bool launchCorrect(const std::string& product, const std::string& app);
38+ bool setupWriteDir(const std::string& product, const std::string& app);
39+ bool setup();
40+
41+ std::string getCompactName();
42+ bool loadDataFromSelf(bool unmountIfMounted = false);
43+
44+ bool fileExists(const std::string& fileName);
45+ bool directoryExists(const std::string& directoryName);
46+
47+ // @dontbind
48+ void readFileStream(const std::string& fileName, std::iostream& out);
49+ std::string readFileContents(const std::string& fileName, bool safe = false);
50+ std::string readFileContentsSafe(const std::string& fileName) { return readFileContents(fileName, true); }
51+ bool isFileEncryptedOrCompressed(const std::string& fileName);
52+ // @dontbind
53+ bool writeFileBuffer(const std::string& fileName, const uchar* data, uint size);
54+ bool writeFileContents(const std::string& fileName, const std::string& data);
55+ // @dontbind
56+ bool writeFileStream(const std::string& fileName, std::iostream& in);
57+
58+ FileStreamPtr openFile(const std::string& fileName, bool dontCache = false);
59+ FileStreamPtr appendFile(const std::string& fileName);
60+ FileStreamPtr createFile(const std::string& fileName);
61+ bool deleteFile(const std::string& fileName);
62+
63+ bool makeDir(const std::string directory);
64+ std::list<std::string> listDirectoryFiles(const std::string & directoryPath = "", bool fullPath = false, bool raw = false);
65+
66+ std::string resolvePath(std::string path);
67+ std::string getWorkDir() { return "/"; }
68+#ifdef ANDROID
69+ std::string getWriteDir() { return "/"; }
70+ std::string getBinaryName() { return "otclientv8.apk"; }
71+#else
72+ std::string getWriteDir() { return m_writeDir.string(); }
73+ std::string getBinaryName() { return m_binaryPath.filename().string(); }
74+#endif
75+
76+ std::string guessFilePath(const std::string& filename, const std::string& type);
77+ bool isFileType(const std::string& filename, const std::string& type);
78+
79+ bool isLoadedFromArchive() { return m_loadedFromArchive; }
80+ bool isLoadedFromMemory() { return m_loadedFromMemory; }
81+
82+ std::string fileChecksum(const std::string& path);
83+
84+ std::map<std::string, std::string> filesChecksums();
85+ std::string selfChecksum();
86+
87+ std::string readCrashLog(bool txt);
88+ void deleteCrashLog();
89+
90+ void updateData(const std::set<std::string>& files, bool reMount);
91+ void updateExecutable(std::string fileName);
92+
93+ std::string createArchive(const std::map<std::string, std::string>& files);
94+ std::map<std::string, std::string> decompressArchive(std::string dataOrPath);
95+
96+#ifdef WITH_ENCRYPTION
97+ void encrypt(const std::string& seed = "");
98+ bool encryptBuffer(std::string & buffer, uint32_t seed = 0);
99+#endif
100+ bool decryptBuffer(std::string & buffer);
101+#if defined(WIN32) && not(defined(FREE_VERSION))
102+ void installDlls(std::filesystem::path dest);
103+#endif
104+
105+ void setLayout(std::string layout);
106+ std::string getLayout()
107+ {
108+ return m_layout;
109+ }
110+
111+private:
112+ bool mountMemoryData(const std::shared_ptr<std::vector<uint8_t>>& data);
113+ void unmountMemoryData();
114+
115+#ifndef ANDROID
116+ std::filesystem::path m_binaryPath, m_writeDir;
117+#endif
118+ bool m_loadedFromMemory = false;
119+ bool m_loadedFromArchive = false;
120+ std::shared_ptr<std::vector<uint8_t>> m_memoryData;
121+ uint32_t m_customEncryption = 0;
122+ std::string m_layout;
123+};
124+
125+extern ResourceManager g_resources;
126+
127+#endif
A RD_Client/src/framework/core/scheduledevent.cpp +57-0 View file
@@ -0,0 +1,57 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#include "scheduledevent.h"
24+
25+ScheduledEvent::ScheduledEvent(const std::string& function, const std::function<void()>& callback, int delay, int maxCycles, bool botSafe) : Event(function, callback, botSafe)
26+{
27+ m_ticks = g_clock.millis() + delay;
28+ m_delay = delay;
29+ m_maxCycles = maxCycles;
30+ m_cyclesExecuted = 0;
31+}
32+
33+void ScheduledEvent::execute()
34+{
35+ if(!m_canceled && m_callback && (m_maxCycles == 0 || m_cyclesExecuted < m_maxCycles)) {
36+ m_callback();
37+ m_executed = true;
38+ // callback may be used in the next cycle
39+ } else {
40+ // reset callback to free object refs
41+ m_callback = nullptr;
42+ }
43+
44+ m_cyclesExecuted++;
45+}
46+
47+bool ScheduledEvent::nextCycle()
48+{
49+ if(m_callback && !m_canceled && (m_maxCycles == 0 || m_cyclesExecuted < m_maxCycles)) {
50+ m_ticks += m_delay;
51+ return true;
52+ }
53+
54+ // reset callback to free object refs
55+ m_callback = nullptr;
56+ return false;
57+}
A RD_Client/src/framework/core/scheduledevent.h +57-0 View file
@@ -0,0 +1,57 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#ifndef SCHEDULEDEVENT_H
24+#define SCHEDULEDEVENT_H
25+
26+#include <framework/global.h>
27+#include "event.h"
28+#include "clock.h"
29+
30+// @bindclass
31+class ScheduledEvent : public Event
32+{
33+public:
34+ ScheduledEvent(const std::string& function, const std::function<void()>& callback, int delay, int maxCycles, bool botSafe = false);
35+ void execute();
36+ bool nextCycle();
37+
38+ int ticks() { return m_ticks; }
39+ int remainingTicks() { return m_ticks - g_clock.millis(); }
40+ int delay() { return m_delay; }
41+ int cyclesExecuted() { return m_cyclesExecuted; }
42+ int maxCycles() { return m_maxCycles; }
43+
44+private:
45+ ticks_t m_ticks;
46+ int m_delay;
47+ int m_maxCycles;
48+ int m_cyclesExecuted;
49+};
50+
51+struct lessScheduledEvent {
52+ bool operator()(const ScheduledEventPtr& a, const ScheduledEventPtr& b) {
53+ return b->ticks() < a->ticks();
54+ }
55+};
56+
57+#endif
A RD_Client/src/framework/core/timer.cpp +36-0 View file
@@ -0,0 +1,36 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+
24+#include "timer.h"
25+#include "clock.h"
26+
27+void Timer::restart()
28+{
29+ m_startTicks = g_clock.millis();
30+ m_stopped = false;
31+}
32+
33+ticks_t Timer::ticksElapsed()
34+{
35+ return g_clock.millis() - m_startTicks;
36+}
A RD_Client/src/framework/core/timer.h +48-0 View file
@@ -0,0 +1,48 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#ifndef TIMER_H
24+#define TIMER_H
25+
26+#include <framework/global.h>
27+
28+class Timer
29+{
30+public:
31+ Timer() { restart(); }
32+
33+ void restart();
34+ void stop() { m_stopped = true; }
35+ void adjust(ticks_t value) { m_startTicks += value; }
36+
37+ ticks_t startTicks() { return m_startTicks; }
38+ ticks_t ticksElapsed();
39+ float timeElapsed() { return ticksElapsed()/1000.0f; }
40+
41+ bool running() { return !m_stopped; }
42+
43+private:
44+ ticks_t m_startTicks;
45+ stdext::boolean<false> m_stopped;
46+};
47+
48+#endif
A RD_Client/src/framework/global.h +56-0 View file
@@ -0,0 +1,56 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#ifndef FRAMEWORK_GLOBAL_H
24+#define FRAMEWORK_GLOBAL_H
25+
26+#include "stdext/compiler.h"
27+
28+// common C/C++ headers
29+#include "pch.h"
30+
31+// error handling
32+#if defined(NDEBUG)
33+#define VALIDATE(expression) ((void)0)
34+#else
35+extern void fatalError(const char* error, const char* file, int line);
36+#define VALIDATE(expression) { if(!(expression)) fatalError(#expression, __FILE__, __LINE__); };
37+#endif
38+
39+
40+// global constants
41+#include "const.h"
42+
43+// stdext which includes additional C++ algorithms
44+#include "stdext/stdext.h"
45+
46+// additional utilities
47+#include "util/point.h"
48+#include "util/color.h"
49+#include "util/rect.h"
50+#include "util/size.h"
51+#include "util/matrix.h"
52+
53+// logger
54+#include "core/logger.h"
55+
56+#endif
A RD_Client/src/framework/graphics/animatedtexture.cpp +80-0 View file
@@ -0,0 +1,80 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#include "animatedtexture.h"
24+#include "graphics.h"
25+
26+#include <framework/core/eventdispatcher.h>
27+
28+AnimatedTexture::AnimatedTexture(const Size& size, std::vector<ImagePtr> frames, std::vector<int> framesDelay, bool buildMipmaps, bool compress) :
29+ Texture(size)
30+{
31+ for(uint i=0;i<frames.size();++i) {
32+ m_frames.push_back(new Texture(frames[i], buildMipmaps, compress));
33+ }
34+
35+ m_framesDelay = framesDelay;
36+ m_hasMipmaps = buildMipmaps;
37+ m_uniqueId = 0;
38+ m_currentFrame = 0;
39+ m_animTimer.restart();
40+ setupTranformMatrix();
41+}
42+
43+AnimatedTexture::~AnimatedTexture()
44+{
45+
46+}
47+
48+bool AnimatedTexture::buildHardwareMipmaps()
49+{
50+ for(const TexturePtr& frame : m_frames)
51+ frame->buildHardwareMipmaps();
52+ m_hasMipmaps = true;
53+ return true;
54+}
55+
56+void AnimatedTexture::setSmooth(bool smooth)
57+{
58+ for(const TexturePtr& frame : m_frames)
59+ frame->setSmooth(smooth);
60+ m_smooth = smooth;
61+}
62+
63+void AnimatedTexture::setRepeat(bool repeat)
64+{
65+ for(const TexturePtr& frame : m_frames)
66+ frame->setRepeat(repeat);
67+ m_repeat = repeat;
68+}
69+
70+void AnimatedTexture::update()
71+{
72+ if (m_animTimer.ticksElapsed() >= m_framesDelay[m_currentFrame]) {
73+ m_animTimer.restart();
74+ m_currentFrame = (m_currentFrame + 1) % m_frames.size();
75+ }
76+
77+ m_frames[m_currentFrame]->update();
78+ m_id = m_frames[m_currentFrame]->getId();
79+ m_uniqueId = m_frames[m_currentFrame]->getUniqueId();
80+}
A RD_Client/src/framework/graphics/animatedtexture.h +53-0 View file
@@ -0,0 +1,53 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#ifndef ANIMATEDTEXTURE_H
24+#define ANIMATEDTEXTURE_H
25+
26+#include "texture.h"
27+#include <framework/core/timer.h>
28+
29+class AnimatedTexture : public Texture
30+{
31+public:
32+ AnimatedTexture(const Size& size, std::vector<ImagePtr> frames, std::vector<int> framesDelay, bool buildMipmaps = false, bool compress = false);
33+ virtual ~AnimatedTexture();
34+
35+ void replace(const ImagePtr& image) { }
36+ void update();
37+
38+ virtual bool isAnimatedTexture() { return true; }
39+
40+protected:
41+ virtual bool buildHardwareMipmaps();
42+
43+ virtual void setSmooth(bool smooth);
44+ virtual void setRepeat(bool repeat);
45+
46+private:
47+ std::vector<TexturePtr> m_frames;
48+ std::vector<int> m_framesDelay;
49+ uint m_currentFrame;
50+ Timer m_animTimer;
51+};
52+
53+#endif
A RD_Client/src/framework/graphics/apngloader.h +46-0 View file
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (c) 2010-2017 OTClient <https://github.com/edubart/otclient>
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+ * THE SOFTWARE.
21+ */
22+
23+#ifndef APNGLOADER_H
24+#define APNGLOADER_H
25+
26+#include <sstream>
27+
28+struct apng_data {
29+ unsigned char *pdata;
30+ unsigned int width;
31+ unsigned int height;
32+ unsigned int first_frame;
33+ unsigned int last_frame;
34+ unsigned char bpp;
35+ unsigned char coltype;
36+ unsigned int num_frames;
37+ unsigned int num_plays;
38+ unsigned short *frames_delay; // each frame delay in ms
39+};
40+
41+// returns -1 on error, 0 on success
42+int load_apng(std::stringstream& file, struct apng_data *apng);
43+void save_png(std::stringstream& file, unsigned int width, unsigned int height, int channels, unsigned char *pixels);
44+void free_apng(struct apng_data *apng);
45+
46+#endif
Top