コード例 #1
0
ファイル: image.c プロジェクト: pts/pts-qiv
void transform( qiv_image *q, enum Orientation orientation) {
    switch (orientation) {
     default: return;
     case HFLIP:     flipH(q); snprintf(infotext, sizeof infotext, "(Flipped horizontally)"); break;
     case VFLIP:     flipV(q); snprintf(infotext, sizeof infotext, "(Flipped vertically)"); break;
     case ROT_180:   rot180(q); snprintf(infotext, sizeof infotext, "(Turned upside down)"); break;
      case TRANSPOSE: transpose(q); swapWH(q); snprintf(infotext, sizeof infotext, "(Transposed)"); break;
     case ROT_90:    rot90(q); swapWH(q); snprintf(infotext, sizeof infotext, "(Rotated left)"); break;
     case TRANSVERSE: transpose(q); rot180(q); swapWH(q); snprintf(infotext, sizeof infotext, "(Transversed)"); break;
     case ROT_270:   rot270(q); swapWH(q); snprintf(infotext, sizeof infotext, "(Rotated left)"); break;
    }
}
コード例 #2
0
ファイル: trans.c プロジェクト: antonmazun/courses
void transposMain(int mat[4][4])
{
	rotateCW270(mat);
	flipV(mat);
}
コード例 #3
0
ファイル: jpeg.cpp プロジェクト: kindex/Steel
bool ResJPEG::init(const std::string& name)
{  

	rstream f;
	
	path = name;

	if(!f.open(name, "jpg"))
	{
		//log_msg("warning res image tga", std::string("Res/Image/TGA: cannot open file ")+ name.c_str());
		return false;
	}

	struct jpeg_decompress_struct cinfo;

	my_error_mgr jerr;

	cinfo.err = jpeg_std_error(&jerr.pub);
	jerr.pub.error_exit = my_error_exit;

	if (setjmp(jerr.setjmp_buffer))
	{
		jpeg_destroy_decompress(&cinfo);
		return false;
	}

	jpeg_create_decompress(&cinfo);
	jpeg_stdio_src(&cinfo, &f);
	jpeg_read_header(&cinfo, TRUE);
	jpeg_start_decompress(&cinfo);

	int stride = cinfo.output_width * cinfo.output_components;
	unsigned char** buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, stride, 1);

	if(createImage(cinfo.output_width, cinfo.output_height, 24) == false)
	{
		f.close();
		return false;
	}

	unsigned char* pBitmap = (unsigned char*)bitmap;
	const int a = 255;
	while (cinfo.output_scanline < cinfo.output_height)
	{
		jpeg_read_scanlines(&cinfo, buffer, 1);
		unsigned char* pcomp = *buffer;

		// in first implementation we move all bytes manually. if this will work, we will replace with memcpy
		for (unsigned int i = 0; i < cinfo.output_width; i++)
		{
			for(int c = 0; c < 3; c++){
				*pBitmap=*pcomp;
				pBitmap++;
				pcomp++;
			}
		}
	}

	jpeg_finish_decompress(&cinfo);
	jpeg_destroy_decompress(&cinfo);

	dimension	= IMAGE_2D;
	format = IMAGE_RGB;

	flipV();
	return true;
}