10 #include "jasper/jasper.h"
41 jas_image_t *image = NULL;
42 jas_stream_t *jpcstream;
43 jas_image_cmpt_t *pcmpt;
54 jas_conf_set_max_mem_usage(10000000);
55 jas_conf_set_multithread(
true);
56 if (jas_init_library())
58 if (jas_init_thread())
67 jpcstream = jas_stream_memopen(injpc, bufsize);
73 if (!(image = jas_image_decode(jpcstream, fmt, opts)))
76 pcmpt = image->cmpts_[0];
101 if (image->numcmpts_ != 1)
106 data = jas_matrix_create(jas_image_height(image), jas_image_width(image));
107 jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image),
108 jas_image_height(image), data);
112 for (i = 0; i < pcmpt->height_; i++)
113 for (j = 0; j < pcmpt->width_; j++)
114 outfld[k++] = data->rows_[i][j];
117 jas_matrix_destroy(data);
118 jas_stream_close(jpcstream);
119 jas_image_destroy(image);
123 jas_cleanup_thread();
124 jas_cleanup_library();