37 struct jpeg_decompress_struct jdat;
38 struct jpeg_error_mgr jerr;
42 jdat.err = jpeg_std_error(&jerr);
43 jpeg_create_decompress(&jdat);
50 fp = fopen(fname,
"rb");
55 jpeg_stdio_src(&jdat, fp);
56 jpeg_read_header(&jdat,
TRUE);
57 jpeg_start_decompress(&jdat);
59 xs = jdat.output_width;
60 ys = jdat.output_height;
61 col = jdat.output_components;
62 if (xs<=0 || ys<=0 || col<=0) {
63 jpeg_destroy_decompress(&jdat);
71 jpeg_destroy_decompress(&jdat);
77 int rmn = jdat.output_height;
79 jpeg_read_scanlines(&jdat, jp.
img+jdat.output_scanline, rmn);
80 rmn = jdat.output_height - jdat.output_scanline;
82 jpeg_finish_decompress (&jdat);
83 jpeg_destroy_decompress(&jdat);
111 struct jpeg_compress_struct jdat;
112 struct jpeg_error_mgr jerr;
119 if (qulty>100) qulty = 100;
120 else if (qulty<0) qulty = 0;
123 fp = fopen(fname,
"wb");
128 jdat.err = jpeg_std_error(&jerr);
129 jpeg_create_compress(&jdat);
136 jpeg_stdio_dest(&jdat, fp);
138 jdat.image_width = jp->
xs;
139 jdat.image_height = jp->
ys;
140 jdat.input_components = jp->
col;
141 if (jp->
col==1) jdat.in_color_space = JCS_GRAYSCALE;
142 else jdat.in_color_space = JCS_RGB;
144 jpeg_set_quality (&jdat, qulty,
TRUE);
145 jpeg_set_defaults(&jdat);
147 jpeg_start_compress (&jdat,
TRUE);
148 jpeg_write_scanlines(&jdat, jp->
img, jp->
ys);
149 jpeg_finish_compress(&jdat);
151 jpeg_destroy_compress(&jdat);
177 struct jpeg_compress_struct jdat;
178 struct jpeg_error_mgr jerr;
187 if (qulty>100) qulty = 100;
188 else if (qulty<0) qulty = 0;
190 *
buf = (
unsigned char*)malloc(*
len);
195 jdat.err = jpeg_std_error(&jerr);
196 jpeg_create_compress(&jdat);
198 jpeg_mem_dest(&jdat,
buf,
len);
200 jdat.image_width = jp->
xs;
201 jdat.image_height = jp->
ys;
202 jdat.input_components = jp->
col;
203 if (jp->
col==1) jdat.in_color_space = JCS_GRAYSCALE;
204 else jdat.in_color_space = JCS_RGB;
206 jpeg_set_quality (&jdat, qulty,
TRUE);
207 jpeg_set_defaults(&jdat);
209 jpeg_start_compress (&jdat,
TRUE);
210 jpeg_write_scanlines(&jdat, jp->
img, jp->
ys);
211 jpeg_finish_compress(&jdat);
212 jpeg_destroy_compress(&jdat);
233 memset(&vp, 0,
sizeof(
WSGraph));
234 if (jp.
gp==NULL || jp.
img==NULL) {
240 if (vp.
gp==NULL)
return vp;
242 for (k=0; k<jp.
col; k++) {
244 for (j=0; j<jp.
ys; j++) {
246 for (i=0; i<jp.
xs; i++) {
267 memset(&vp, 0,
sizeof(
BSGraph));
268 if (jp.
gp==NULL || jp.
img==NULL) {
274 if (vp.
gp==NULL)
return vp;
276 for (k=0; k<jp.
col; k++) {
278 for (j=0; j<jp.
ys; j++) {
280 for (i=0; i<jp.
xs; i++) {
306 if (jp.
gp==NULL || jp.
img==NULL)
return jp;
308 for (k=0; k<vp.
zs; k++) {
310 for (j=0; j<vp.
ys; j++) {
312 for (i=0; i<vp.
xs; i++) {
313 jp.
img[j][i*vp.
zs + k] = vp.
gp[yp + i];
337 if (jp.
gp==NULL || jp.
img==NULL)
return jp;
339 for (k=0; k<vp.
zs; k++) {
341 for (j=0; j<vp.
ys; j++) {
343 for (i=0; i<vp.
xs; i++) {
344 jp.
img[j][i*vp.
zs + k] = vp.
gp[yp + i];
362 if (xs==0 || ys==0) {
368 jp.
img = (JSAMPARRAY)malloc(
sizeof(JSAMPROW)*ys);
374 jp.
gp = (JSAMPLE*)malloc(
sizeof(JSAMPLE)*col*xs*ys);
381 for (j=0; j<ys; j++) {
382 jp.
img[j] = (JSAMPROW)&jp.
gp[j*col*xs];
398 if (jp==NULL)
return;
412#if JPEG_LIB_VERSION < 80
415METHODDEF(
void) mem_init_destination(j_compress_ptr cinfo)
421METHODDEF(
boolean) mem_empty_output_buffer(j_compress_ptr cinfo)
428 nextbuffer = (JOCTET*)malloc(nextsize);
430 if (nextbuffer == NULL)
return FALSE;
437 dest->
pub.next_output_byte = nextbuffer + dest->
bufsize;
439 dest->
buffer = nextbuffer;
446METHODDEF(
void) mem_term_destination(j_compress_ptr cinfo)
450 *dest->outbuffer = dest->buffer;
451 *dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
455GLOBAL(
void) jpeg_mem_dest(j_compress_ptr cinfo,
unsigned char**
buf,
unsigned long*
len)
460 if (cinfo->dest == NULL) {
461 cinfo->dest = (
struct jpeg_destination_mgr*)
466 dest->
pub.init_destination = mem_init_destination;
467 dest->
pub.empty_output_buffer = mem_empty_output_buffer;
468 dest->
pub.term_destination = mem_term_destination;
469 dest->
pub.next_output_byte = *
buf;
470 dest->
pub.free_in_buffer = *
len;
BSGraph make_BSGraph(int xs, int ys, int zs)
WSGraph make_WSGraph(int xs, int ys, int zs)
#define JBXL_GRAPH_IVDARG_ERROR
無効な引数
#define JBXL_GRAPH_NODATA_ERROR
データが無い
#define JBXL_GRAPH_ERROR
GRAPH ライブラリーのエラー
#define JBXL_GRAPH_OPFILE_ERROR
ファイルのオープンエラー
#define JBXL_GRAPH_IVDCOLOR_ERROR
無効なカラー指定
#define JBXL_GRAPH_HEADER_ERROR
画像ヘッダーのエラー
#define JBXL_GRAPH_MEMORY_ERROR
メモリエラー
int zs
zサイズ. 4Byte. 2Dの場合は 1.
uByte * gp
グラフィックデータへのポインタ. xs*ys*zs*1Byte.
int zs
zサイズ. 4Byte. 2Dの場合は 1.
sWord * gp
グラフィックデータへのポインタ. xs*ys*zs*2Byte.
unsigned char ** outbuffer
struct jpeg_destination_mgr pub
unsigned char * newbuffer