1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (image_transfer.c).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include <formats/rpng.h>
32 #include <formats/rjpeg.h>
35 #include <formats/rtga.h>
38 #include <formats/rbmp.h>
41 #include <formats/image.h>
43 void image_transfer_free(void *data, enum image_type_enum type)
49 rtga_free((rtga_t*)data);
55 rpng_t *rpng = (rpng_t*)data;
63 rjpeg_free((rjpeg_t*)data);
68 rbmp_free((rbmp_t*)data);
76 void *image_transfer_new(enum image_type_enum type)
111 bool image_transfer_start(void *data, enum image_type_enum type)
118 if (!rpng_start((rpng_t*)data))
124 case IMAGE_TYPE_JPEG:
138 case IMAGE_TYPE_NONE:
145 bool image_transfer_is_valid(
147 enum image_type_enum type)
153 return rpng_is_valid((rpng_t*)data);
157 case IMAGE_TYPE_JPEG:
171 case IMAGE_TYPE_NONE:
178 void image_transfer_set_buffer_ptr(
180 enum image_type_enum type,
188 rpng_set_buf_ptr((rpng_t*)data, (uint8_t*)ptr, len);
191 case IMAGE_TYPE_JPEG:
193 rjpeg_set_buf_ptr((rjpeg_t*)data, (uint8_t*)ptr);
198 rtga_set_buf_ptr((rtga_t*)data, (uint8_t*)ptr);
203 rbmp_set_buf_ptr((rbmp_t*)data, (uint8_t*)ptr);
206 case IMAGE_TYPE_NONE:
211 int image_transfer_process(
213 enum image_type_enum type,
214 uint32_t **buf, size_t len,
215 unsigned *width, unsigned *height)
221 return rpng_process_image(
223 (void**)buf, len, width, height);
227 case IMAGE_TYPE_JPEG:
229 return rjpeg_process_image((rjpeg_t*)data,
230 (void**)buf, len, width, height);
236 return rtga_process_image((rtga_t*)data,
237 (void**)buf, len, width, height);
243 return rbmp_process_image((rbmp_t*)data,
244 (void**)buf, len, width, height);
248 case IMAGE_TYPE_NONE:
255 bool image_transfer_iterate(void *data, enum image_type_enum type)
262 if (!rpng_iterate_image((rpng_t*)data))
266 case IMAGE_TYPE_JPEG:
280 case IMAGE_TYPE_NONE: