cake
/
libg1m
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libg1m/include/libg1m/picture.h

71 lines
2.5 KiB
C

/* *****************************************************************************
* libg1m/picture.h -- libg1m picture formats.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libg1m.
* libg1m is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version.
*
* libg1m is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libg1m; if not, see <http://www.gnu.org/licenses/>.
* ************************************************************************** */
#ifndef LIBG1M_PICTURE_H
# define LIBG1M_PICTURE_H
# ifdef __cplusplus
extern "C" {
# endif
/* picture format */
typedef int g1m_pictureformat_t;
# define g1m_pictureformat_1bit_packed 0x0101
# define g1m_pictureformat_1bit_reverse 0x0102
# define g1m_pictureformat_2bit_dual 0x0201
# define g1m_pictureformat_4bit_rgb 0x0401
# define g1m_pictureformat_4bit_code 0x0402
# define g1m_pictureformat_4bit_color 0x0403
# define g1m_pictureformat_4bit_mono 0x0404
# define g1m_pictureformat_16bit 0x1000
/* get size of the raw buffer */
# define g1m_picturesize_1bit_packed(W, H) \
((W) * (H) / 8)
# define g1m_picturesize_1bit_reverse(W, H) \
g1m_picturesize_1bit_packed(W, H)
# define g1m_picturesize_1bit_color(W, H) \
(4 * g1m_picturesize_1bit_reverse(W, H))
# define g1m_picturesize_1bit_mono(W, H) \
g1m_picturesize_1bit_color(W, H)
# define g1m_picturesize_2bit_dual(W, H) \
(((W) * (H) / 4) * 2)
# define g1m_picturesize_4bit(W, H) \
((W) * (H) / 2)
# define g1m_picturesize_4bit_rgb(W, H) \
g1m_picturesize_4bit(W, H)
# define g1m_picturesize_4bit_code(W, H) \
g1m_picturesize_4bit(W, H)
# define g1m_picturesize_16bit(W, H) \
((W) * (H) * 2)
/* encoding and decoding functions */
extern int g1m_decode_picture(uint32_t **pixels,
g1m_pictureformat_t format, const unsigned char *raw,
unsigned int width, unsigned int height);
extern int g1m_encode_picture(const uint32_t **pixels,
g1m_pictureformat_t format, unsigned char *raw,
unsigned int width, unsigned int height);
# ifdef __cplusplus
}
# endif
#endif /* LIBG1M_PICTURE_H */