/* ***************************************************************************** * decode/cas/screenshot.c -- decode a CAS screenshot. * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey * * 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 . * ************************************************************************** */ #include /** * g1m_decode_caspart_capture: * Decode a CAS picture. * * @arg handle the handle to contribute to. * @arg buffer the buffer to read from. * @return the error code (0 if ok). */ int g1m_decode_caspart_capture(g1m_mcsfile_t *handle, g1m_buffer_t *buffer) { /* read the picture data */ unsigned int width = handle->head.width, height = handle->head.height; size_t pic_size = g1m_picturesize_4bit_color(width, height); uint8_t pic_data[pic_size]; READ(pic_data, pic_size) /* decode the picture data */ int err = g1m_decode_picture(handle->pics[0], handle->head._picformat, pic_data, width, height); if (err) { g1m_free_mcsfile(handle); return (err); } /* no error */ handle->head.flags &= ~g1m_mcsflag_unfinished; return (0); }