48 lines
1.8 KiB
C
48 lines
1.8 KiB
C
/* *****************************************************************************
|
|
* decode/cas/screenshot.c -- decode a CAS screenshot.
|
|
* 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/>.
|
|
* ************************************************************************** */
|
|
#include <libg1m/internals.h>
|
|
|
|
/**
|
|
* 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->g1m_mcsfile_head.g1m_mcshead_width;
|
|
unsigned int height = handle->g1m_mcsfile_head.g1m_mcshead_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->g1m_mcsfile_pics[0],
|
|
handle->g1m_mcsfile_head.g1m_mcshead_picformat,
|
|
pic_data, width, height);
|
|
if (err) { g1m_free_mcsfile(handle); return (err); }
|
|
|
|
/* no error */
|
|
handle->g1m_mcsfile_head.g1m_mcshead_flags &= ~g1m_mcsflag_unfinished;
|
|
return (0);
|
|
}
|