コード例 #1
0
ファイル: gif.c プロジェクト: aosm/tcl
static int
ChnMatch(
    Tcl_Channel chan,		/* The image channel, open for reading. */
    const char *fileName,	/* The name of the image file. */
    Tcl_Obj *format,		/* User-specified format object, or NULL. */
    int *widthPtr,	        /* The dimensions of the image are */
	int *heightPtr,			/* returned here if the file is a valid
				 * raw GIF file. */
    Tcl_Interp *interp		/* interpreter */
) {
    GIFImageConfig gifConf;

    memset(&gifConf, 0, sizeof(GIFImageConfig));

    gifConf.handle.data = (char *) chan;
    gifConf.handle.state = IMG_CHAN;

    return ReadGIFHeader(&gifConf, widthPtr, heightPtr);
}
コード例 #2
0
ファイル: GIFLoad.cpp プロジェクト: pipe0xffff/haiku
GIFLoad::GIFLoad(BPositionIO* input, BPositionIO* output)
	:
	fatalerror(false),
	fInput(input),
	fOutput(output),
	fPalette(NULL),
 	fHeadMemblock(NULL),
	fScanLine(NULL)
{
	fInput->Seek(0, SEEK_SET);

	if (!ReadGIFHeader()) {
		fatalerror = true;
		return;
	}

	if (debug) {
		syslog(LOG_INFO, "GIFLoad::GIFLoad() - Image dimensions are %d x %d\n",
			fWidth, fHeight);
	}

	unsigned char c;
	if (fInput->Read(&c, 1) < 1) {
		fatalerror = true;
		return;
	}

	while (c != TERMINATOR_INTRODUCER) {
		if (c == DESCRIPTOR_INTRODUCER) {
			if ((!ReadGIFImageHeader()) || (!ReadGIFImageData())) {
				if (debug) {
					syslog(LOG_ERR, "GIFLoad::GIFLoad() - "
						"A fatal error occurred\n");
				}

				fatalerror = true;
			} else {
				if (debug) {
					syslog(LOG_INFO, "GIFLoad::GIFLoad() - "
						"Found a single image and leaving\n");
				}
			}
			free(fScanLine);
			fScanLine = NULL;
			return;
		} else if (c == EXTENSION_INTRODUCER) {
			unsigned char d;
			if (fInput->Read(&d, 1) < 1) {
				fatalerror = true;
				return;
			}
			if (d == LOOP_BLOCK_LABEL) {
				if (!ReadGIFLoopBlock()) {
					fatalerror = true;
					return;
				}
			} else if (d == GRAPHIC_CONTROL_LABEL) {
				if (!ReadGIFControlBlock()) {
					fatalerror = true;
					return;
				}
			} else if (d == COMMENT_EXTENSION_LABEL) {
				if (!ReadGIFCommentBlock()) {
					fatalerror = true;
					return;
				}
			} else {
				if (!ReadGIFUnknownBlock(d)) {
					fatalerror = true;
					return;
				}
			}
		} else if (c != BLOCK_TERMINATOR) {
			if (!ReadGIFUnknownBlock(c)) {
				fatalerror = true;
				return;
			}
		}

		if (fInput->Read(&c, 1) < 1) {
			fatalerror = true;
			return;
		}
	}

	if (debug)
		syslog(LOG_INFO, "GIFLoad::GIFLoad() - Done\n");
}
コード例 #3
0
ファイル: GIFLoad.cpp プロジェクト: jiangxilong/haiku
GIFLoad::GIFLoad(BPositionIO *input, BPositionIO *output)
	:
	fatalerror(false),
	fInput(input),
	fOutput(output),
	fPalette(NULL),
 	fHeadMemblock(NULL),
	fScanLine(NULL)
{
	fInput->Seek(0, SEEK_SET);

	if (!ReadGIFHeader()) {
		fatalerror = true;
		return;
	}
	
	if (debug)
		syslog(LOG_ERR, "GIFLoad::GIFLoad() - Image dimensions are %d x %d\n",
				fWidth, fHeight);
	
	unsigned char c;
	if (fInput->Read(&c, 1) < 1) {
		fatalerror = true;
		return;
	}
	while (c != 0x3b) {
		if (c == 0x2c) {
			if ((!ReadGIFImageHeader()) || (!ReadGIFImageData())) {
				if (debug) 
					syslog(LOG_ERR, "GIFLoad::GIFLoad() - A fatal error occurred\n");
				fatalerror = true;
			} else {
				if (debug) 
					syslog(LOG_ERR, "GIFLoad::GIFLoad() - Found a single image and "
						"leaving\n");
			}
			free(fScanLine);
			fScanLine = NULL;
			return;
		} else if (c == 0x21) {
			unsigned char d;
			if (fInput->Read(&d, 1) < 1) {
				fatalerror = true;
				return;
			}
			if (d == 0xff) {
				if (!ReadGIFLoopBlock()) {
					fatalerror = true;
					return;
				}
			} else if (d == 0xf9) {
				if (!ReadGIFControlBlock()) {
					fatalerror = true;
					return;
				}
			} else if (d == 0xfe) {
				if (!ReadGIFCommentBlock()) {
					fatalerror = true;
					return;
				}
			} else {
				if (!ReadGIFUnknownBlock(d)) {
					fatalerror = true;
					return;
				}
			}
		} else if (c != 0x00) {
			if (!ReadGIFUnknownBlock(c)) {
				fatalerror = true;
				return;
			}
		}
		if (fInput->Read(&c, 1) < 1) {
			fatalerror = true;
			return;
		}
	}
	if (debug)
		syslog(LOG_ERR, "GIFLoad::GIFLoad() - Done\n");
}