Exemplo n.º 1
0
BOOL fipImage::flipHorizontal() {
	if(_dib) {
		_bHasChanged = TRUE;

		return FreeImage_FlipHorizontal(_dib);
	}
	return FALSE;
}
Exemplo n.º 2
0
/*!
 *	\brief Opens the image file using the FreeImage library in the specified orientation
 * 		   and builds the 2D Texture MipMaps.
 *	\param pathImagefile Path to the image file.
 *	\param bVertFlip	1, if the image texture must be vertically flipped
 * 						0, otherwise
 *	\param bHorzFlip	1, if the image texture must be horizontally flipped
 * 						0, otherwise 
 *	\return Texture ID.
 */
GLuint loadTexture(const char* pathImagefile, int bVertFlip, int bHorzFlip)
{
	GLuint textureID;
	
    FREE_IMAGE_FORMAT format = FreeImage_GetFileType(pathImagefile,0);
	FIBITMAP* image = FreeImage_Load(format, pathImagefile,0);
	int bRGBA = FreeImage_IsTransparent(image);
	
	FIBITMAP* temp = image;
	if(bRGBA)
	{
		image = FreeImage_ConvertTo32Bits(temp);
	}
	else
	{
		image = FreeImage_ConvertTo24Bits(temp);
	}
	FreeImage_Unload(temp);	
	
	if(bVertFlip)
	{
		FreeImage_FlipVertical(image);
	}
	
	if(bHorzFlip)
	{
		FreeImage_FlipHorizontal(image);
	}	
	
	int w = FreeImage_GetWidth(image);
	int h = FreeImage_GetHeight(image);
	
	glGenTextures(1, &textureID);
	glBindTexture(GL_TEXTURE_2D, textureID);
	
	//// turn off bilinear filtering
	//gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
	//gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)	
	
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	if(bRGBA)
	{
		gluBuild2DMipmaps(GL_TEXTURE_2D, 4, w, h, GL_BGRA, GL_UNSIGNED_BYTE, FreeImage_GetBits(image));
	}
	else
	{
		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, w, h, GL_BGR, GL_UNSIGNED_BYTE, FreeImage_GetBits(image));	
	}

	FreeImage_Unload(image);
	
	return textureID;
}
Exemplo n.º 3
0
static void 
rotate_exif(FIBITMAP **dib) {
	// check for Exif rotation
	if(FreeImage_GetMetadataCount(FIMD_EXIF_MAIN, *dib)) {
		FIBITMAP *rotated = NULL;
		// process Exif rotation
		FITAG *tag = NULL;
		FreeImage_GetMetadata(FIMD_EXIF_MAIN, *dib, "Orientation", &tag);
		if(tag != NULL) {
			if(FreeImage_GetTagID(tag) == TAG_ORIENTATION) {
				unsigned short orientation = *((unsigned short *)FreeImage_GetTagValue(tag));
				switch (orientation) {
					case 1:		// "top, left side" => 0°
						break;
					case 2:		// "top, right side" => flip left-right
						FreeImage_FlipHorizontal(*dib);
						break;
					case 3:		// "bottom, right side"; => -180°
						rotated = FreeImage_Rotate(*dib, 180);
						FreeImage_Unload(*dib);
						*dib = rotated;
						break;
					case 4:		// "bottom, left side" => flip up-down
						FreeImage_FlipVertical(*dib);
						break;
					case 5:		// "left side, top" => +90° + flip up-down
						rotated = FreeImage_Rotate(*dib, 90);
						FreeImage_Unload(*dib);
						*dib = rotated;
						FreeImage_FlipVertical(*dib);
						break;
					case 6:		// "right side, top" => -90°
						rotated = FreeImage_Rotate(*dib, -90);
						FreeImage_Unload(*dib);
						*dib = rotated;
						break;
					case 7:		// "right side, bottom" => -90° + flip up-down
						rotated = FreeImage_Rotate(*dib, -90);
						FreeImage_Unload(*dib);
						*dib = rotated;
						FreeImage_FlipVertical(*dib);
						break;
					case 8:		// "left side, bottom" => +90°
						rotated = FreeImage_Rotate(*dib, 90);
						FreeImage_Unload(*dib);
						*dib = rotated;
						break;
					default:
						break;
				}
			}
		}
	}
}
Exemplo n.º 4
0
//----------------------------------------------------
void ofxImage::flipPixels(ofPixels &pix, bool horizontal, bool vertical){
	if(!horizontal && !vertical)
		return;
	
	FIBITMAP * bmp               = getBmpFromPixels(pix);
	bool horSuccess = false, vertSuccess = false;
	
	if(horizontal)
		horSuccess = FreeImage_FlipHorizontal(bmp);
	if(vertical)
		vertSuccess = FreeImage_FlipVertical(bmp);
	
	if(horSuccess || vertSuccess)
		putBmpIntoPixels(bmp, pix);
	
	if (bmp != NULL)            FreeImage_Unload(bmp);
}
Exemplo n.º 5
0
bool Webcam::saveFrame(string sFilename, bool bMirror)
{
	if(!use) return false;
	if(!m_curFrame) return false;
#ifdef USE_VIDEOINPUT
	FIBITMAP* bmp = FreeImage_ConvertFromRawBits(m_curFrame, m_iWidth, m_iHeight, m_iWidth * 3, 24, 0x0000FF, 0x00FF00, 0xFF0000, true);
#elif !defined(NO_WEBCAM)
	FIBITMAP* bmp = FreeImage_ConvertFromRawBits(m_curFrame->data, m_iWidth, m_iHeight, m_iWidth * 3, 24, 0x0000FF, 0x00FF00, 0xFF0000, true);
#else
  FIBITMAP* bmp = NULL;
#endif
	if(!bmp) return false;
	if(bMirror)
		FreeImage_FlipHorizontal(bmp);
#ifdef USE_VIDEOINPUT
	FreeImage_FlipVertical(bmp);
#endif
	bool bRet = FreeImage_Save(FIF_JPEG, bmp, sFilename.c_str());
	FreeImage_Unload(bmp);
	return bRet;
}
Exemplo n.º 6
0
/**
 * Horizontal inversion. Returns 0 if there is no image loaded.
 */
bool IND_Image::flipHorizontal() {
	// No image loaded
	if (!isImageLoaded()) return false;

	return FreeImage_FlipHorizontal(getFreeImageHandle()) != 0;
}
Exemplo n.º 7
0
void poImage::flip(poOrientation dir) {
	if(dir == PO_VERTICAL)
		FreeImage_FlipVertical(bitmap);
	else
		FreeImage_FlipHorizontal(bitmap);
}