home *** CD-ROM | disk | FTP | other *** search
- /* ICC_R . C
- #
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- This software is copyright (C) by the Lawrence Berkeley Laboratory.
- Permission is granted to reproduce this software for non-commercial
- purposes provided that this notice is left intact.
-
- It is acknowledged that the U.S. Government has rights to this software
- under Contract DE-AC03-765F00098 between the U.S. Department of Energy
- and the University of California.
-
- This software is provided as a professional and academic contribution
- for joint exchange. Thus, it is experimental, and is provided ``as is'',
- with no warranties of any kind whatsoever, no support, no promise of
- updates, or printed documentation. By using this software, you
- acknowledge that the Lawrence Berkeley Laboratory and Regents of the
- University of California shall have no liability with respect to the
- infringement of other copyrights by any part of this software.
-
- For further information about this notice, contact William Johnston,
- Bld. 50B, Rm. 2239, Lawrence Berkeley Laboratory, Berkeley, CA, 94720.
- (wejohnston@lbl.gov)
-
- For further information about this software, contact:
- Jin Guojun
- Bld. 50B, Rm. 2275, Lawrence Berkeley Laboratory, Berkeley, CA, 94720.
- g_jin@lbl.gov
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % The input file is an either padded to 8-pixel in width,
- % or any 3-separate-plane images.
- % The output can be: SGF, ILC, ILL, or SEP.
- %
- % AUTHOR: Jin Guojun - LBL 10/01/1991
- */
-
- #include "header.def"
- #include "imagedef.h"
-
-
- read_sepplane_image(img, cnt, frames)
- U_IMAGE *img;
- {
- char junk[16], *tmp;
- register int ch=img->channels, i=img->color_form;
- int fsize = img->width * img->height, ret, f=0,
- sep_to_sg = img->in_color==CFM_SEPLANE && (i==CFM_SGF || i==CFM_ILC);
-
- if (img->in_type != HIPS || !img->src)
- verify_buffer_size(&img->src, fsize, img->dpy_channels, "sep-buf");
- tmp = img->src;
- if (cnt < 0) cnt = 0;
- if (sep_to_sg) tmp = nzalloc(ch, fsize, "sep-tmp");
-
- { register char *op; /* The default is to convert to RLE */
- register int row, inc = img->width * (i==CFM_ILL ? ch : 1);
-
- do {
- op = tmp;
- for (ch=0; ch<img->channels; ch++) {
- if (img->color_form == CFM_ILL)
- op = tmp + img->width * ch;
- for (row=i=0; row++ < img->height; op+=inc) {
- i += (*img->read)(op, 1, img->width, img->IN_FP);
- if (cnt && !(*img->read)(junk, cnt, 1, img->IN_FP))
- break;
- }
- if (i != fsize) {
- prgmerr(DEBUGANY, "[%d] read SEP data[%d] %d", ch, fsize, i);
- break;
- }
- }
- if ((ret = i) < 1) break;
- if (sep_to_sg) {
- op = img->src;
- op += f * (i=fsize) * img->dpy_channels;
- if (img->color_form == CFM_SGF) /* convert 3-channel to 1 */
- ill_to_gray(op, tmp, tmp+i, tmp+(i<<1), i);
- else {
- register char *r=tmp, *g=r+i, *b=g+i;
- while (i--)
- *op++ = *r++, *op++ = *g++, *op++ = *b++;
- }
- }
- if (!sep_to_sg) tmp += fsize * img->dpy_channels;
- } while(++f < frames);
- }
-
- if (sep_to_sg) free(tmp);
- if (img->mid_type == RLE) /* safety for RLE map_scan */
- img->channels = img->dpy_channels;
- return ret;
- }
-