Exemplo n.º 1
0
void Format::printAll()
{
	// All format information... 
	printf(
		"Image size info:\n"			\
		"    width:\t\t %d\n"			\
		"    height:\t\t %d\n"			\
		"    bytes per line:\t %d\n"	\
		"    image buffer size:\t %d\n"	\
		"\nImage format info:\n"		\
		"    pixel format:\t %s\n"		\
		"    colorspace:\t\t %s\n"		\
		"    field:\t\t %s\n",

		getWidth(),
		getHeight(),
		getBytesPerLine(),
		getImageSize(),
		getPixelFormat(),
		getColorspace(),
		getField()
	);

	switch(state) {
		case FORMAT_IS_DIRTY:
			printf("\nFormat state has not yet been applied.\n");
			break;
		case FORMAT_IS_NULL:
			printf("\nFormat has not yet been fetched.\n");
			break;
		case FORMAT_FAILED_UPDATE:
			printf("\nFormat state update failed to apply cleanly.\n");
			break;
		case FORMAT_IS_CLEAN:
		default:
			break;
	}
}
Exemplo n.º 2
0
int main(void)
{

	char *filename = "./test.jpg";

	/* Open JPEG image file. Don't forget to use b for binary. */
	FILE *file = fopen(filename, "rb");
	if (!file) {
		printf("Error opening jpeg file %s\n", filename);
		return -1;
	}

	/*
	* This struct contains the JPEG compression parameters and pointers to
	* working space (which is allocated as needed by the JPEG library).
	*/
	struct jpeg_decompress_struct cinfo;

	/*
	* This struct represents a JPEG error handler.
	*/
	struct jpeg_error_mgr jerr;

	/* Setup the error handler */
	cinfo.err = jpeg_std_error(&jerr);

	/* Initialize JPEG decompression object */
	jpeg_create_decompress(&cinfo);

	/* Specify input file */
	jpeg_stdio_src(&cinfo, file);

	/* Read JPEG file header */
	(void)jpeg_read_header(&cinfo, TRUE);

	/* Get colorspace */
	int colorspace = getColorspace(cinfo);

	/* Print colorspace name based on other int */
	switch (colorspace) {
	case 3:
		printf("Image colorspace is RGB\n");
		break;

	case 1:
		printf("Image colorspace is grayscale\n");
		break;

	default:
		printf("No colorspace recognized");
		break;
	}	

	/* Release memory */
	jpeg_destroy_decompress(&cinfo);

	/* Close input file */
	fclose(file);

	system("pause");

	return 0;
}