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

Function pixReadHeaderMem

deps/leptonica/src/readfile.c:947–1067  ·  view source on GitHub ↗

! * \brief pixReadHeaderMem() * * \param[in] data const; encoded * \param[in] size size of data * \param[out] pformat [optional] image format * \param[out] pw, ph [optional] width and height * \param[out] pbps [optional] bits/sample * \param[out] pspp [optional] samples/pixel 1, 3 or 4 * \param[out] piscmap [optional] 1 if cmap exists; 0 otherwise * \return 0 if OK, 1

Source from the content-addressed store, hash-verified

945 * </pre>
946 */
947l_int32
948pixReadHeaderMem(const l_uint8 *data,
949 size_t size,
950 l_int32 *pformat,
951 l_int32 *pw,
952 l_int32 *ph,
953 l_int32 *pbps,
954 l_int32 *pspp,
955 l_int32 *piscmap)
956{
957l_int32 format, ret, w, h, d, bps, spp, iscmap;
958l_int32 type; /* not used */
959PIX *pix;
960
961 PROCNAME("pixReadHeaderMem");
962
963 if (pw) *pw = 0;
964 if (ph) *ph = 0;
965 if (pbps) *pbps = 0;
966 if (pspp) *pspp = 0;
967 if (piscmap) *piscmap = 0;
968 if (pformat) *pformat = 0;
969 iscmap = 0; /* init to false */
970 if (!data)
971 return ERROR_INT("data not defined", procName, 1);
972 if (size < 8)
973 return ERROR_INT("size < 8", procName, 1);
974
975 findFileFormatBuffer(data, &format);
976
977 switch (format)
978 {
979 case IFF_BMP: /* cheating: read the pix */
980 if ((pix = pixReadMemBmp(data, size)) == NULL)
981 return ERROR_INT( "bmp: pix not read", procName, 1);
982 pixGetDimensions(pix, &w, &h, &d);
983 pixDestroy(&pix);
984 bps = (d == 32) ? 8 : d;
985 spp = (d == 32) ? 3 : 1;
986 break;
987
988 case IFF_JFIF_JPEG:
989 ret = readHeaderMemJpeg(data, size, &w, &h, &spp, NULL, NULL);
990 bps = 8;
991 if (ret)
992 return ERROR_INT( "jpeg: no header info returned", procName, 1);
993 break;
994
995 case IFF_PNG:
996 ret = readHeaderMemPng(data, size, &w, &h, &bps, &spp, &iscmap);
997 if (ret)
998 return ERROR_INT( "png: no header info returned", procName, 1);
999 break;
1000
1001 case IFF_TIFF:
1002 case IFF_TIFF_PACKBITS:
1003 case IFF_TIFF_RLE:
1004 case IFF_TIFF_G3:

Callers 1

pixcompCreateFromStringFunction · 0.85

Calls 12

findFileFormatBufferFunction · 0.85
pixGetDimensionsFunction · 0.85
pixDestroyFunction · 0.85
sreadHeaderSpixFunction · 0.85
pixReadMemBmpFunction · 0.70
readHeaderMemJpegFunction · 0.70
readHeaderMemPngFunction · 0.70
readHeaderMemTiffFunction · 0.70
readHeaderMemPnmFunction · 0.70
pixReadMemGifFunction · 0.70
readHeaderMemJp2kFunction · 0.70
readHeaderMemWebPFunction · 0.70

Tested by

no test coverage detected