MCPcopy Create free account
hub / github.com/LibRaw/LibRaw / dcraw_make_mem_thumb

Method dcraw_make_mem_thumb

src/postprocessing/mem_image.cpp:17–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "../../internal/libraw_cxx_defs.h"
16
17libraw_processed_image_t *LibRaw::dcraw_make_mem_thumb(int *errcode)
18{
19 if (!T.thumb)
20 {
21 if (!ID.toffset && !(imgdata.thumbnail.tlength > 0 &&
22 load_raw == &LibRaw::broadcom_load_raw) // RPi
23 )
24 {
25 if (errcode)
26 *errcode = LIBRAW_NO_THUMBNAIL;
27 }
28 else
29 {
30 if (errcode)
31 *errcode = LIBRAW_OUT_OF_ORDER_CALL;
32 }
33 return NULL;
34 }
35
36 if (T.tlength < 64u)
37 {
38 if (errcode)
39 *errcode = EINVAL;
40 return NULL;
41 }
42
43 if (INT64(T.tlength) > 1024ULL * 1024ULL * LIBRAW_MAX_THUMBNAIL_MB)
44 {
45 if (errcode)
46 *errcode = LIBRAW_TOO_BIG;
47 return NULL;
48 }
49
50 if (T.tformat == LIBRAW_THUMBNAIL_BITMAP)
51 {
52 libraw_processed_image_t *ret = (libraw_processed_image_t *)::malloc(
53 sizeof(libraw_processed_image_t) + T.tlength);
54
55 if (!ret)
56 {
57 if (errcode)
58 *errcode = ENOMEM;
59 return NULL;
60 }
61
62 memset(ret, 0, sizeof(libraw_processed_image_t));
63 ret->type = LIBRAW_IMAGE_BITMAP;
64 ret->height = T.theight;
65 ret->width = T.twidth;
66 if (T.tcolors > 0 && T.tcolors < 4)
67 ret->colors = T.tcolors;
68 else
69 ret->colors = 3; // defaults
70 ret->bits = 8;
71 ret->data_size = T.tlength;
72 memmove(ret->data, T.thumb, T.tlength);
73 if (errcode)
74 *errcode = 0;

Callers 2

mainFunction · 0.45

Calls 2

mallocFunction · 0.85
tiff_headFunction · 0.85

Tested by

no test coverage detected