⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tif_getimage.c

📁 奇趣公司比较新的qt/emd版本
💻 C
📖 第 1 页 / 共 5 页
字号:
    }					\    if (_x > 0) {			\	op1;				\	CASE8(_x,op2);			\    }					\}#define	UNROLL4(w, op1, op2) {		\    uint32 _x;				\    for (_x = w; _x >= 4; _x -= 4) {	\	op1;				\	REPEAT4(op2);			\    }					\    if (_x > 0) {			\	op1;				\	CASE4(_x,op2);			\    }					\}#define	UNROLL2(w, op1, op2) {		\    uint32 _x;				\    for (_x = w; _x >= 2; _x -= 2) {	\	op1;				\	REPEAT2(op2);			\    }					\    if (_x) {				\	op1;				\	op2;				\    }					\}    #define	SKEW(r,g,b,skew)	{ r += skew; g += skew; b += skew; }#define	SKEW4(r,g,b,a,skew)	{ r += skew; g += skew; b += skew; a+= skew; }#define A1 (((uint32)0xffL)<<24)#define	PACK(r,g,b)	\	((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1)#define	PACK4(r,g,b,a)	\	((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24))#define W2B(v) (((v)>>8)&0xff)#define	PACKW(r,g,b)	\	((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1)#define	PACKW4(r,g,b,a)	\	((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|((uint32)W2B(a)<<24))#define	DECLAREContigPutFunc(name) \static void name(\    TIFFRGBAImage* img, \    uint32* cp, \    uint32 x, uint32 y, \    uint32 w, uint32 h, \    int32 fromskew, int32 toskew, \    unsigned char* pp \)/* * 8-bit palette => colormap/RGB */DECLAREContigPutFunc(put8bitcmaptile){    uint32** PALmap = img->PALmap;    int samplesperpixel = img->samplesperpixel;    (void) y;    while (h-- > 0) {	for (x = w; x-- > 0;)        {	    *cp++ = PALmap[*pp][0];            pp += samplesperpixel;        }	cp += toskew;	pp += fromskew;    }}/* * 4-bit palette => colormap/RGB */DECLAREContigPutFunc(put4bitcmaptile){    uint32** PALmap = img->PALmap;    (void) x; (void) y;    fromskew /= 2;    while (h-- > 0) {	uint32* bw;	UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++);	cp += toskew;	pp += fromskew;    }}/* * 2-bit palette => colormap/RGB */DECLAREContigPutFunc(put2bitcmaptile){    uint32** PALmap = img->PALmap;    (void) x; (void) y;    fromskew /= 4;    while (h-- > 0) {	uint32* bw;	UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++);	cp += toskew;	pp += fromskew;    }}/* * 1-bit palette => colormap/RGB */DECLAREContigPutFunc(put1bitcmaptile){    uint32** PALmap = img->PALmap;    (void) x; (void) y;    fromskew /= 8;    while (h-- > 0) {	uint32* bw;	UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++);	cp += toskew;	pp += fromskew;    }}/* * 8-bit greyscale => colormap/RGB */DECLAREContigPutFunc(putgreytile){    int samplesperpixel = img->samplesperpixel;    uint32** BWmap = img->BWmap;    (void) y;    while (h-- > 0) {	for (x = w; x-- > 0;)        {	    *cp++ = BWmap[*pp][0];            pp += samplesperpixel;        }	cp += toskew;	pp += fromskew;    }}/* * 16-bit greyscale => colormap/RGB */DECLAREContigPutFunc(put16bitbwtile){    int samplesperpixel = img->samplesperpixel;    uint32** BWmap = img->BWmap;    (void) y;    while (h-- > 0) {        uint16 *wp = (uint16 *) pp;	for (x = w; x-- > 0;)        {            /* use high order byte of 16bit value */	    *cp++ = BWmap[*wp >> 8][0];            pp += 2 * samplesperpixel;            wp += samplesperpixel;        }	cp += toskew;	pp += fromskew;    }}/* * 1-bit bilevel => colormap/RGB */DECLAREContigPutFunc(put1bitbwtile){    uint32** BWmap = img->BWmap;    (void) x; (void) y;    fromskew /= 8;    while (h-- > 0) {	uint32* bw;	UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++);	cp += toskew;	pp += fromskew;    }}/* * 2-bit greyscale => colormap/RGB */DECLAREContigPutFunc(put2bitbwtile){    uint32** BWmap = img->BWmap;    (void) x; (void) y;    fromskew /= 4;    while (h-- > 0) {	uint32* bw;	UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++);	cp += toskew;	pp += fromskew;    }}/* * 4-bit greyscale => colormap/RGB */DECLAREContigPutFunc(put4bitbwtile){    uint32** BWmap = img->BWmap;    (void) x; (void) y;    fromskew /= 2;    while (h-- > 0) {	uint32* bw;	UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++);	cp += toskew;	pp += fromskew;    }}/* * 8-bit packed samples, no Map => RGB */DECLAREContigPutFunc(putRGBcontig8bittile){    int samplesperpixel = img->samplesperpixel;    (void) x; (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	UNROLL8(w, NOP,	    *cp++ = PACK(pp[0], pp[1], pp[2]);	    pp += samplesperpixel);	cp += toskew;	pp += fromskew;    }}/* * 8-bit packed samples, w/ Map => RGB */DECLAREContigPutFunc(putRGBcontig8bitMaptile){    TIFFRGBValue* Map = img->Map;    int samplesperpixel = img->samplesperpixel;    (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	for (x = w; x-- > 0;) {	    *cp++ = PACK(Map[pp[0]], Map[pp[1]], Map[pp[2]]);	    pp += samplesperpixel;	}	pp += fromskew;	cp += toskew;    }}/* * 8-bit packed samples => RGBA w/ associated alpha * (known to have Map == NULL) */DECLAREContigPutFunc(putRGBAAcontig8bittile){    int samplesperpixel = img->samplesperpixel;    (void) x; (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	UNROLL8(w, NOP,	    *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]);	    pp += samplesperpixel);	cp += toskew;	pp += fromskew;    }}/* * 8-bit packed samples => RGBA w/ unassociated alpha * (known to have Map == NULL) */DECLAREContigPutFunc(putRGBUAcontig8bittile){    int samplesperpixel = img->samplesperpixel;    (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	uint32 r, g, b, a;	for (x = w; x-- > 0;) {	    a = pp[3];	    r = (pp[0] * a) / 255;	    g = (pp[1] * a) / 255;	    b = (pp[2] * a) / 255;	    *cp++ = PACK4(r,g,b,a);	    pp += samplesperpixel;	}	cp += toskew;	pp += fromskew;    }}/* * 16-bit packed samples => RGB */DECLAREContigPutFunc(putRGBcontig16bittile){    int samplesperpixel = img->samplesperpixel;    uint16 *wp = (uint16 *)pp;    (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	for (x = w; x-- > 0;) {	    *cp++ = PACKW(wp[0], wp[1], wp[2]);	    wp += samplesperpixel;	}	cp += toskew;	wp += fromskew;    }}/* * 16-bit packed samples => RGBA w/ associated alpha * (known to have Map == NULL) */DECLAREContigPutFunc(putRGBAAcontig16bittile){    int samplesperpixel = img->samplesperpixel;    uint16 *wp = (uint16 *)pp;    (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	for (x = w; x-- > 0;) {	    *cp++ = PACKW4(wp[0], wp[1], wp[2], wp[3]);	    wp += samplesperpixel;	}	cp += toskew;	wp += fromskew;    }}/* * 16-bit packed samples => RGBA w/ unassociated alpha * (known to have Map == NULL) */DECLAREContigPutFunc(putRGBUAcontig16bittile){    int samplesperpixel = img->samplesperpixel;    uint16 *wp = (uint16 *)pp;    (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	uint32 r,g,b,a;	/*	 * We shift alpha down four bits just in case unsigned	 * arithmetic doesn't handle the full range.	 * We still have plenty of accuracy, since the output is 8 bits.	 * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff)	 * Since we want r*a * 0xff for eight bit output,	 * we divide by (0xffff * 0xfff) / 0xff == 0x10eff.	 */	for (x = w; x-- > 0;) {	    a = wp[3] >> 4; 	    r = (wp[0] * a) / 0x10eff;	    g = (wp[1] * a) / 0x10eff;	    b = (wp[2] * a) / 0x10eff;	    *cp++ = PACK4(r,g,b,a);	    wp += samplesperpixel;	}	cp += toskew;	wp += fromskew;    }}/* * 8-bit packed CMYK samples w/o Map => RGB * * NB: The conversion of CMYK->RGB is *very* crude. */DECLAREContigPutFunc(putRGBcontig8bitCMYKtile){    int samplesperpixel = img->samplesperpixel;    uint16 r, g, b, k;    (void) x; (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	UNROLL8(w, NOP,	    k = 255 - pp[3];	    r = (k*(255-pp[0]))/255;	    g = (k*(255-pp[1]))/255;	    b = (k*(255-pp[2]))/255;	    *cp++ = PACK(r, g, b);	    pp += samplesperpixel);	cp += toskew;	pp += fromskew;    }}/* * 8-bit packed CMYK samples w/Map => RGB * * NB: The conversion of CMYK->RGB is *very* crude. */DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile){    int samplesperpixel = img->samplesperpixel;    TIFFRGBValue* Map = img->Map;    uint16 r, g, b, k;    (void) y;    fromskew *= samplesperpixel;    while (h-- > 0) {	for (x = w; x-- > 0;) {	    k = 255 - pp[3];	    r = (k*(255-pp[0]))/255;	    g = (k*(255-pp[1]))/255;	    b = (k*(255-pp[2]))/255;	    *cp++ = PACK(Map[r], Map[g], Map[b]);	    pp += samplesperpixel;	}	pp += fromskew;	cp += toskew;    }}#define	DECLARESepPutFunc(name) \static void name(\    TIFFRGBAImage* img,\    uint32* cp,\    uint32 x, uint32 y, \    uint32 w, uint32 h,\    int32 fromskew, int32 toskew,\    unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a\)/* * 8-bit unpacked samples => RGB */DECLARESepPutFunc(putRGBseparate8bittile){    (void) img; (void) x; (void) y; (void) a;    while (h-- > 0) {	UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++));	SKEW(r, g, b, fromskew);	cp += toskew;    }}/* * 8-bit unpacked samples => RGB */DECLARESepPutFunc(putRGBseparate8bitMaptile){    TIFFRGBValue* Map = img->Map;    (void) y; (void) a;    while (h-- > 0) {	for (x = w; x > 0; x--)	    *cp++ = PACK(Map[*r++], Map[*g++], Map[*b++]);	SKEW(r, g, b, fromskew);	cp += toskew;    }}/* * 8-bit unpacked samples => RGBA w/ associated alpha */DECLARESepPutFunc(putRGBAAseparate8bittile){    (void) img; (void) x; (void) y;    while (h-- > 0) {	UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++));	SKEW4(r, g, b, a, fromskew);	cp += toskew;    }}/* * 8-bit unpacked samples => RGBA w/ unassociated alpha */DECLARESepPutFunc(putRGBUAseparate8bittile){    (void) img; (void) y;    while (h-- > 0) {	uint32 rv, gv, bv, av;	for (x = w; x-- > 0;) {	    av = *a++;	    rv = (*r++ * av) / 255;	    gv = (*g++ * av) / 255;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -