示例#1
0
文件: IoImage.c 项目: Alessandroo/io
IoObject *IoImage_makeRGBA8(IoImage *self, IoObject *locals, IoMessage *m)
{
	/*doc Image makeRGBA8
	Converts color model to RGBA 8bit. Returns self.
	*/
	Image_makeRGBA(DATA(self)->image);
	return self;
}
示例#2
0
文件: Image.c 项目: iamaleksey/io
void Image_load(Image *self)
{
	if (strcmp(self->fileType, "png")==0)
	{
		PNGImage *image = PNGImage_new();
		PNGImage_setExternalUArray_(image, self->byteArray);
		PNGImage_path_(image, self->path);
		PNGImage_load(image);
		Image_error_(self, PNGImage_error(image));
		self->width  = PNGImage_width(image);
		self->height = PNGImage_height(image);
		self->componentCount = PNGImage_components(image);
		PNGImage_free(image);
	}
	else if (strcmp(self->fileType, "jpg")==0)
	{
		JPGImage *image = JPGImage_new();
		JPGImage_setExternalUArray_(image, self->byteArray);
		JPGImage_path_(image, self->path);
		JPGImage_decodingWidthHint_(image, self->decodingWidthHint);
		JPGImage_decodingHeightHint_(image, self->decodingHeightHint);
		JPGImage_load(image);
		Image_error_(self, JPGImage_error(image));
		self->width  = JPGImage_width(image);
		self->height = JPGImage_height(image);
		self->componentCount = JPGImage_components(image);
		JPGImage_free(image);
	}
	else if (strcmp(self->fileType, "tif")==0 || strcmp(self->fileType, "tiff")==0)
	{
		TIFFImage *image = TIFFImage_new();
		TIFFImage_setExternalUArray_(image, self->byteArray);
		TIFFImage_path_(image, self->path);
		TIFFImage_load(image);
		Image_error_(self, TIFFImage_error(image));
		self->width  = TIFFImage_width(image);
		self->height = TIFFImage_height(image);
		self->componentCount = TIFFImage_components(image);
		TIFFImage_free(image);
	}
	else
	{
		Image_error_(self, "unknown file type");
	}

	if (UArray_size(self->byteArray) == 0)
	{
		Image_error_(self, "error reading file");
	}

	Image_makeRGBA(self);
}