FreeRDP
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 */
32 BOOL 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 
52 fail:
53  winpr_image_free(image, TRUE);
54  return rc;
55 }
56 
57 #else
58 
59 BOOL jpeg_decompress(const BYTE* input, BYTE* output, int width, int height, int size, int bpp)
60 {
61  return 0;
62 }
63 
64 #endif