MCPcopy Create free account
hub / github.com/creatale/node-dv / pixcompCreateFromString

Function pixcompCreateFromString

deps/leptonica/src/pixcomp.c:241–272  ·  view source on GitHub ↗

! * \brief pixcompCreateFromString() * * \param[in] data compressed string * \param[in] size number of bytes * \param[in] copyflag L_INSERT or L_COPY * \return pixc, or NULL on error * * * Notes: * (1) This works when the compressed string is png, jpeg or tiffg4. * (2) The copyflag determines if the data in the new Pixcomp is * a copy of the input d

Source from the content-addressed store, hash-verified

239 * </pre>
240 */
241PIXC *
242pixcompCreateFromString(l_uint8 *data,
243 size_t size,
244 l_int32 copyflag)
245{
246l_int32 format, w, h, d, bps, spp, iscmap;
247PIXC *pixc;
248
249 PROCNAME("pixcompCreateFromString");
250
251 if (!data)
252 return (PIXC *)ERROR_PTR("data not defined", procName, NULL);
253 if (copyflag != L_INSERT && copyflag != L_COPY)
254 return (PIXC *)ERROR_PTR("invalid copyflag", procName, NULL);
255
256 if (pixReadHeaderMem(data, size, &format, &w, &h, &bps, &spp, &iscmap) == 1)
257 return (PIXC *)ERROR_PTR("header data not read", procName, NULL);
258 if ((pixc = (PIXC *)LEPT_CALLOC(1, sizeof(PIXC))) == NULL)
259 return (PIXC *)ERROR_PTR("pixc not made", procName, NULL);
260 d = (spp == 3) ? 32 : bps * spp;
261 pixc->w = w;
262 pixc->h = h;
263 pixc->d = d;
264 pixc->comptype = format;
265 pixc->cmapflag = iscmap;
266 if (copyflag == L_INSERT)
267 pixc->data = data;
268 else
269 pixc->data = l_binaryCopy(data, size);
270 pixc->size = size;
271 return pixc;
272}
273
274
275/*!

Callers 1

pixcompCreateFromFileFunction · 0.85

Calls 2

pixReadHeaderMemFunction · 0.85
l_binaryCopyFunction · 0.85

Tested by

no test coverage detected