FreeRDP
Loading...
Searching...
No Matches
jpeg.c
1
20#include <freerdp/config.h>
21
22#include <winpr/stream.h>
23#include <winpr/image.h>
24
25#include <freerdp/codec/color.h>
26
27#include <freerdp/codec/jpeg.h>
28
29#ifdef WITH_JPEG
30
31/* jpeg decompress */
32BOOL jpeg_decompress(const BYTE* input, BYTE* output, int width, int height, int size, int bpp)
33{
34 BOOL rc = FALSE;
35
36 if (bpp != 24)
37 return FALSE;
38
39 wImage* image = winpr_image_new();
40 if (!image)
41 goto fail;
42
43 if (winpr_image_read_buffer(image, input, size) <= 0)
44 goto fail;
45
46 if ((image->width != width) || (image->height != height) || (image->bitsPerPixel != bpp))
47 goto fail;
48
49 memcpy(output, image->data, 1ull * image->scanline * image->height);
50 rc = TRUE;
51
52fail:
53 winpr_image_free(image, TRUE);
54 return rc;
55}
56
57#else
58
59BOOL jpeg_decompress(WINPR_ATTR_UNUSED const BYTE* input, WINPR_ATTR_UNUSED BYTE* output,
60 WINPR_ATTR_UNUSED int width, WINPR_ATTR_UNUSED int height,
61 WINPR_ATTR_UNUSED int size, WINPR_ATTR_UNUSED int bpp)
62{
63 WLog_ERR("TODO", "TODO: implement");
64 return 0;
65}
66
67#endif