| 1 | /* APNG Disassembler 2.9  |
| 2 | *  |
| 3 | * Deconstructs APNG files into individual frames.  |
| 4 | *  |
| 5 | * http://apngdis.sourceforge.net  |
| 6 | *  |
| 7 | * Copyright (c) 2010-2017 Max Stepin  |
| 8 | * maxst at users.sourceforge.net  |
| 9 | *  |
| 10 | * zlib license  |
| 11 | * ------------  |
| 12 | *  |
| 13 | * This software is provided 'as-is', without any express or implied  |
| 14 | * warranty. In no event will the authors be held liable for any damages  |
| 15 | * arising from the use of this software.  |
| 16 | *  |
| 17 | * Permission is granted to anyone to use this software for any purpose,  |
| 18 | * including commercial applications, and to alter it and redistribute it  |
| 19 | * freely, subject to the following restrictions:  |
| 20 | *  |
| 21 | * 1. The origin of this software must not be misrepresented; you must not  |
| 22 | * claim that you wrote the original software. If you use this software  |
| 23 | * in a product, an acknowledgment in the product documentation would be  |
| 24 | * appreciated but is not required.  |
| 25 | * 2. Altered source versions must be plainly marked as such, and must not be  |
| 26 | * misrepresented as being the original software.  |
| 27 | * 3. This notice may not be removed or altered from any source distribution.  |
| 28 | *  |
| 29 | */  |
| 30 | //////////////////////////////////////////////////////////////////////////////////////  |
| 31 | // This is a modified version of apngdis //  |
| 32 | // //  |
| 33 | // The modifications were made by Tristan Grimmer and are primarily to remove //  |
| 34 | // main so the functionality can be called directly from other source files. //  |
| 35 | // A header file has been created to allow external access. //  |
| 36 | // //  |
| 37 | // All modifications should be considered to be covered by the zlib license above. //  |
| 38 | //////////////////////////////////////////////////////////////////////////////////////  |
| 39 |   |
| 40 | #pragma once  |
| 41 | #include <stdio.h>  |
| 42 | #include <stdlib.h>  |
| 43 | #include <string.h>  |
| 44 | #include <vector>  |
| 45 |   |
| 46 | // @tacent Added version string. Value taken from printf in main().  |
| 47 | #define APNGDIS_VERSION_STRING "2.9"  |
| 48 |   |
| 49 | // @tacent Put it all in a namespace.  |
| 50 | namespace APngDis  |
| 51 | {  |
| 52 |   |
| 53 |   |
| 54 | struct Image  |
| 55 | {  |
| 56 | typedef unsigned char * ROW;  |
| 57 | unsigned int w, h, bpp, delay_num, delay_den;  |
| 58 | unsigned char * p;  |
| 59 | ROW * rows;  |
| 60 | Image() : w(0), h(0), bpp(0), delay_num(1), delay_den(10), p(0), rows(0) { }  |
| 61 | ~Image() { }  |
| 62 | void init(unsigned int w1, unsigned int h1, unsigned int bpp1)  |
| 63 | {  |
| 64 | w = w1; h = h1; bpp = bpp1;  |
| 65 | int rowbytes = w * bpp;  |
| 66 | rows = new ROW[h];  |
| 67 | rows[0] = p = new unsigned char[h * rowbytes];  |
| 68 | for (unsigned int j=1; j<h; j++)  |
| 69 | rows[j] = rows[j-1] + rowbytes;  |
| 70 | }  |
| 71 | void free() { delete[] rows; delete[] p; }  |
| 72 | };  |
| 73 |   |
| 74 | // Returns -1 on error.  |
| 75 | int load_apng(const char * szIn, std::vector<Image>& img);  |
| 76 |   |
| 77 |   |
| 78 | }  |
| 79 | |