1 // -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; -*- 2 // (c) 2021 Henner Zeller <h.zeller@acm.org> 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation version 2. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with this program. If not, see <http://gnu.org/licenses/gpl-2.0.txt> 15 16 #ifndef TIMG_PNG_H 17 #define TIMG_PNG_H 18 19 #include <stdint.h> 20 #include <unistd.h> 21 22 namespace timg { 23 class Framebuffer; 24 25 // Encode framebuffer as PNG into given buffer. 26 // "compression_level" is the compression level; 0 means essentially plain 27 // bytes without compression, 1 and more compresses. For our use-case probably 28 // only 1 is ever needed (we want to be fast) 29 // 30 // If "do_32_bit_alpha" is enabled, then RGBA data is encoded, otherwise 31 // 24 bit RGB. 32 enum class ColorEncoding { 33 kRGBA_32, 34 kRGB_24, 35 }; 36 size_t EncodePNG(const Framebuffer &fb, int compression_level, 37 ColorEncoding encoding, 38 char *buffer, size_t size); 39 40 } 41 #endif // TIMG_PNG_H 42