Ejemplo n.º 1
0
static void
tiff_read(unsigned char *dst, unsigned int line, void *data)
{
    struct tiff_state *h = data;
    int s,on,off;

    if (h->image) {
	/* loaded whole image using TIFFReadRGBAImage() */
	uint32 *row = h->image + h->width * (h->height - line -1);
	load_rgba(dst,(unsigned char*)row,h->width);
	return;
    }
    
    if (h->config == PLANARCONFIG_CONTIG) {
	TIFFReadScanline(h->tif, h->row, line, 0);
    } else if (h->config == PLANARCONFIG_SEPARATE) {
	for (s = 0; s < h->nsamples; s++)
	    TIFFReadScanline(h->tif, h->row, line, s);
    }

    switch (h->nsamples) {
    case 1:
	if (1 == h->depth) {
	    /* black/white */
	    on = 0, off = 0;
	    if (PHOTOMETRIC_MINISWHITE == h->photometric)
		on = 0, off = 255;
	    if (PHOTOMETRIC_MINISBLACK == h->photometric)
		on = 255, off = 0;
#if 0
	    /* Huh?  Does TIFFReadScanline handle this already ??? */
	    if (FILLORDER_MSB2LSB == h->fillorder)
		load_bits_msb(dst,(unsigned char*)(h->row),h->width,on,off);
	    else
		load_bits_lsb(dst,(unsigned char*)(h->row),h->width,on,off);
#else
	    load_bits_msb(dst,(unsigned char*)(h->row),h->width,on,off);
#endif
	} else {
	    /* grayscaled */
	    load_gray(dst,(unsigned char*)(h->row),h->width);
	}
	break;
    case 3:
	/* rgb */
	memcpy(dst,h->row,3*h->width);
	break;
    case 4:
	/* rgb+alpha */
	load_rgba(dst,(unsigned char*)(h->row),h->width);
	break;
    }
}
Ejemplo n.º 2
0
ImageLoad( long version, GlobalFunc *global, LWImageLoaderLocal *local,
           void *serverData )
{
    PicInfo *pic = NULL;
    int result;

    if ( version != LWIMAGELOADER_VERSION ) return AFUNC_BADVERSION;

    pic = ReadILBM( local->filename, &result );

    if ( !pic ) {
        switch ( result ) {
        case EPNOFILE:
            local->result = IPSTAT_BADFILE;
            break;
        case EPNOMEM:
            local->result = IPSTAT_FAILED;
            break;
        default:
            local->result = IPSTAT_NOREC;
            break;
        }
        return AFUNC_OK;
    }

    if (( pic->bmhd.nPlanes == 24 ) || ( pic->camg & CAMG_HAM ))
        load_24( local, pic );
    else if ( pic->isgray )
        load_gray( local, pic );
    else
        load_indexed( local, pic );

    FreeILBM( pic );

    return AFUNC_OK;
}