• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FreeImage_Save函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FreeImage_Save函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeImage_Save函数的具体用法?C++ FreeImage_Save怎么用?C++ FreeImage_Save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FreeImage_Save函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: exportImage

/* Exports the left and right eye view as images */
void exportImage(void) {
	unsigned char *image;
	image = (unsigned char*)malloc((3*Settings::pixelWidth*Settings::pixelHeight)*sizeof(char));
	
	
	glPixelStorei(GL_PACK_ALIGNMENT,1);
	
	// Left Image
	glReadBuffer(GL_BACK_LEFT);
	glReadPixels(0, 0, (int)Settings::pixelWidth, (int)Settings::pixelHeight, 
				 GL_BGR,GL_UNSIGNED_BYTE, image);
	
	FIBITMAP* leftImage = FreeImage_ConvertFromRawBits(image, (int)Settings::pixelWidth, 
													   (int)Settings::pixelHeight, 
													   3*Settings::pixelWidth, 24, 0xFF0000, 
													   0x00FF00, 0x0000FF, false); 
	FreeImage_Save(FIF_BMP, leftImage, "left.bmp", 0);
	
	// Right image
	glReadBuffer(GL_BACK_RIGHT);
	glReadPixels(0, 0, (int)Settings::pixelWidth, (int)Settings::pixelHeight,
				 GL_BGR, GL_UNSIGNED_BYTE, image);
	
	FIBITMAP* rightImage = FreeImage_ConvertFromRawBits(image, (int)Settings::pixelWidth, 
														(int)Settings::pixelHeight, 
														3*Settings::pixelWidth, 24, 0xFF0000, 
														0x00FF00, 0x0000FF, false); 
	FreeImage_Save(FIF_BMP, rightImage, "right.bmp", 0);
	
	free(image);
}
开发者ID:biomood,项目名称:3D-Ink,代码行数:32,代码来源:main.cpp


示例2: process_image

bool process_image(std::string infile, std::string outfile, double brightness, double gamma)
{
	DIR *editdir = opendir("img/edit");
	struct dirent *file;
	while ((file = readdir(editdir)) != NULL)
	{
		if (strcmp(file -> d_name, outfile.c_str()) == 0)
		{
			return false;
		}
	}
	closedir(editdir);
	infile = "img/" + infile;
	outfile = "img/edit/" + outfile;
	FIBITMAP *input = FreeImage_Load(FIF_PNG, infile.c_str());
	if (input == NULL)
	{
		std::cerr << "Failed to load " << infile << std::endl;
		exit(1);
	}
	if (!FreeImage_Save(FIF_PNG, input, outfile.c_str()))
	{
		FreeImage_Unload(input);
		std::cerr << "Failed to save " << outfile << std::endl;
		exit(1);
	}
	FreeImage_Unload(input);
	FIBITMAP *output = FreeImage_Load(FIF_PNG, outfile.c_str());
	if (output == NULL)
	{
		std::cerr << "Failed to load " << outfile << std::endl;
		exit(1);
	}
	unsigned int img_w = FreeImage_GetWidth(output);
	unsigned int img_h = FreeImage_GetHeight(output);
	RGBQUAD pixel;
	for (unsigned int x = 0; x < img_w; x++)
	{
		for (unsigned int y = 0; y < img_h; y++)
		{
			FreeImage_GetPixelColor(output, x, y, &pixel);
			pixel.rgbRed = int(clamp(0, pixel.rgbRed * brightness, 255));
			pixel.rgbBlue = int(clamp(0, pixel.rgbBlue * brightness, 255));
			pixel.rgbGreen = int(clamp(0, pixel.rgbGreen * brightness, 255));
			pixel.rgbRed = int(clamp(0, pow(((double) pixel.rgbRed) / 255.0f, gamma) * 255.0, 255));
			pixel.rgbBlue = int(clamp(0, pow(((double) pixel.rgbBlue) / 255.0f, gamma) * 255.0, 255));
			pixel.rgbGreen = int(clamp(0, pow(((double) pixel.rgbGreen) / 255.0f, gamma) * 255.0, 255));
			FreeImage_SetPixelColor(output, x, y, &pixel);
		}
	}
	if (!FreeImage_Save(FIF_PNG, output, outfile.c_str()))
	{
		FreeImage_Unload(input);
		std::cerr << "Failed to save " << outfile << std::endl;
		exit(1);
	}
	FreeImage_Unload(output);
	return true;
}
开发者ID:fosted3,项目名称:ducking-octo-happiness,代码行数:59,代码来源:main.cpp


示例3: storeFreeImage

  void storeFreeImage(const Ref<Image>& img, const FileName& fileName)
  {
      FIBITMAP* dib = FreeImage_Allocate((int)img->width, (int)img->height, 24);

      for(size_t y = 0; y < img->height; y++)
      {
          for(size_t x = 0; x < img->width; x++)
          {
			  Color4 c = img->get(x, y);
              
              RGBQUAD Value = {0};
              Value.rgbRed   = (BYTE)(clamp(c.r) * 255.0f);
              Value.rgbGreen = (BYTE)(clamp(c.g) * 255.0f);
              Value.rgbBlue  = (BYTE)(clamp(c.b) * 255.0f);

              FreeImage_SetPixelColor(dib, (unsigned int)x, (unsigned int)y, &Value);
          }
      }

      FIBITMAP* fiLogo = loadWatermark();

      unsigned int LogoWidth  = FreeImage_GetWidth (fiLogo);
      unsigned int LogoHeight = FreeImage_GetHeight(fiLogo);

      if(LogoWidth > img->width || LogoHeight > img->height)
      {
          FreeImage_Unload(fiLogo);

          FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(fileName.c_str());
          if(FreeImage_FIFSupportsWriting(fif))
              FreeImage_Save(fif, dib, fileName.c_str());

          FreeImage_Unload(dib);
      }
      else
      {
          int x_pos = (int)img->width  - LogoWidth;
          int y_pos = (int)img->height - LogoHeight;

          FIBITMAP* fiFG = FreeImage_Allocate((int)img->width, (int)img->height, 32);
          BOOL b = FreeImage_Paste(fiFG, fiLogo, x_pos, y_pos, 255);
          FreeImage_Unload(fiLogo);

          FIBITMAP* fiNew = FreeImage_Composite(fiFG, FALSE, NULL, dib);
          FreeImage_Unload(dib);

          FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(fileName.c_str());

          int save_flags = 0;
          if(fif == FIF_JPEG)
              save_flags = JPEG_QUALITYSUPERB | JPEG_BASELINE | JPEG_OPTIMIZE;

          if(FreeImage_FIFSupportsWriting(fif))
              FreeImage_Save(fif, fiNew, fileName.c_str(), save_flags);

          FreeImage_Unload(fiNew);
      }
  }
开发者ID:remledevries,项目名称:Theseus-2.4,代码行数:58,代码来源:image_wrapper.cpp


示例4: ofLog

//----------------------------------------------------------------
void  ofImage::saveImageFromPixels(string fileName, ofPixels &pix){

	if (pix.bAllocated == false){
		ofLog(OF_LOG_ERROR,"error saving image - pixels aren't allocated");
		return;
	}

	#ifdef TARGET_LITTLE_ENDIAN
		if (pix.bytesPerPixel != 1) swapRgb(pix);
	#endif

	FIBITMAP * bmp	= getBmpFromPixels(pix);

	#ifdef TARGET_LITTLE_ENDIAN
		if (pix.bytesPerPixel != 1) swapRgb(pix);
	#endif

	fileName = ofToDataPath(fileName);
	if (pix.bAllocated == true){
		FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
		fif = FreeImage_GetFileType(fileName.c_str(), 0);
		if(fif == FIF_UNKNOWN) {
			// or guess via filename
			fif = FreeImage_GetFIFFromFilename(fileName.c_str());
		}
		if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
			FreeImage_Save(fif, bmp, fileName.c_str(), 0);
		}
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
}
开发者ID:andyli,项目名称:openFrameworks,代码行数:35,代码来源:ofImage.cpp


示例5: capture

void capture()
{
	if (doo > 0){ doo = 0; }
	else{ doo++; return; }
	if (capture_frame >= 250) exit(0);

	int mWin_width = 800;
	int mWin_height = 600;
	// Make the BYTE array, factor of 3 because it's RBG.
	BYTE* pixels = new BYTE[3 * mWin_width * mWin_height];

	glReadPixels(0, 0, mWin_width, mWin_height, GL_RGB, GL_UNSIGNED_BYTE, pixels);
	for (int i = 0; i < mWin_height; i++)
		for (int j = 0; j < mWin_width; j++)
		{
			BYTE tmp = pixels[i*(mWin_width * 3) + (j * 3) + 0];
			pixels[i*(mWin_width * 3) + (j * 3) + 0] = pixels[i*(mWin_width * 3) + (j * 3) + 2];
			pixels[i*(mWin_width * 3) + (j * 3) + 2] = tmp;
		}

	// Convert to FreeImage format & save to file
	FIBITMAP* image = FreeImage_ConvertFromRawBits(pixels, mWin_width, mWin_height, 3 * mWin_width, 24, 0xFF0000, 0x00FF00, 0x0000FF, false);
	char filename[200];
	sprintf(filename, "F:/Result_Seen/temp/Image/%05d.png", capture_frame);
	capture_frame++;
	FreeImage_Save(FIF_PNG, image, filename, 0);

	// Free resources
	FreeImage_Unload(image);
	delete[] pixels;
}
开发者ID:expect017,项目名称:CG_Baseball,代码行数:31,代码来源:main.cpp


示例6: write_img

static int
write_img(char *name, const greyscale_image *img) {
  FIBITMAP *image;
  RGBQUAD aPixel;
  int i,j;

  image = FreeImage_Allocate(img->width, img->height, 24, 0, 0, 0);
  if(!image) {
    perror("FreeImage_Allocate");
    return -1;
  }
  for(i = 0; i < img->height; i++) {
    for(j = 0; j < img->width; j++) {
      float v = img->v[i*img->width + j];
      if (v > 1.0) v = 1.0;
      else if (v < 0) v = 0.0;
      v *= 255.0;

      aPixel.rgbRed = (unsigned char) v;
      aPixel.rgbGreen = (unsigned char) v;
      aPixel.rgbBlue = (unsigned char) v;

      FreeImage_SetPixelColor(image, j, i, &aPixel);
    }
  }
  if(!FreeImage_Save(FIF_JPEG, image, name, 0)) {
    perror("FreeImage_Save");
  }
  FreeImage_Unload(image);

  return 0;
}
开发者ID:peddie,项目名称:quasicrystals,代码行数:32,代码来源:quasicrystal.c


示例7: write_image

  void write_image(const string& file, const SampleBuffer& buffer)
  {
    const float samples = static_cast<float>(buffer.samples());
    FIBITMAP* dib = FreeImage_Allocate(buffer.width(), buffer.height(),
        32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);

    const unsigned int BYTESPP =
      FreeImage_GetLine(dib) / FreeImage_GetWidth(dib);
    for (unsigned int y = 0; y < FreeImage_GetHeight(dib); ++y) {
      BYTE* bits = FreeImage_GetScanLine(dib, y);

      for (unsigned int x = 0; x < FreeImage_GetWidth(dib); ++x) {
        vec3 c = gamma_correct(buffer.get(x, y) / samples) * 255.0f;
        bits[FI_RGBA_RED]   = static_cast<BYTE>(c.r);
        bits[FI_RGBA_GREEN] = static_cast<BYTE>(c.g);
        bits[FI_RGBA_BLUE]  = static_cast<BYTE>(c.b);
        bits[FI_RGBA_ALPHA] = 255;

        bits += BYTESPP;
      }
    }

    if (!FreeImage_Save(FIF_PNG, dib, file.c_str(), 0)) {
      string err = "Failed to save screenshot to file '";
      err += file;
      err += '\'';
      throw err;
    }

    FreeImage_Unload(dib);
  }
开发者ID:skyrpex,项目名称:pathtracer,代码行数:31,代码来源:samplebuffer.cpp


示例8: test32BitsChannels

void test32BitsChannels(unsigned width, unsigned height) {
	BOOL bResult = FALSE;

	// create a test 8-bit image
	FIBITMAP *src = createZonePlateImage(width, height, 128);
	if(src != NULL) {
		// convert to 32-bit
		FIBITMAP *tmp = FreeImage_ConvertTo32Bits(src);
		FreeImage_Unload(src);
		src = tmp;
	}
	assert(src != NULL);

	// save for further examination
	bResult = FreeImage_Save(FIF_PNG, src, "zoneplate.png", PNG_DEFAULT);
	assert(bResult);

	// test get/set channel
	// -------------------------	
	FIBITMAP *channel = FreeImage_GetChannel(src, FICC_ALPHA);
	assert(channel != NULL);
	bResult = FreeImage_SetChannel(src, channel, FICC_ALPHA);
	assert(bResult);	
	FreeImage_Unload(channel);

	FreeImage_Unload(src);
}
开发者ID:dschaefer,项目名称:dasEngine,代码行数:27,代码来源:testChannels.cpp


示例9: FreeImage_GetFIFFromFilename

BOOL fipImage::save(const char* lpszPathName, int flag) const {
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	BOOL bSuccess = FALSE;

	// Try to guess the file format from the file extension
	fif = FreeImage_GetFIFFromFilename(lpszPathName);
	if(fif != FIF_UNKNOWN ) {
		// Check that the dib can be saved in this format
		BOOL bCanSave;

		FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(_dib);
		if(image_type == FIT_BITMAP) {
			// standard bitmap type
			WORD bpp = FreeImage_GetBPP(_dib);
			bCanSave = (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportBPP(fif, bpp));
		} else {
			// special bitmap type
			bCanSave = FreeImage_FIFSupportsExportType(fif, image_type);
		}

		if(bCanSave) {
			bSuccess = FreeImage_Save(fif, _dib, lpszPathName, flag);
			return bSuccess;
		}
	}
	return bSuccess;
}
开发者ID:MrMasterplan,项目名称:PIC-stuff,代码行数:27,代码来源:fipImage.cpp


示例10: GenericWriter

/** Generic image writer
@param dib Pointer to the dib to be saved
@param lpszPathName Pointer to the full file name
@param flag Optional save flag constant
@return Returns true if successful, returns false otherwise
*/
bool GenericWriter(const bitmap_ptr& dib, const std::string& lpszPathName, int flag) {
	auto fif = FIF_UNKNOWN;
	auto bSuccess = FALSE;
	// check if file path is not empty
	if (lpszPathName.empty())
		return false;
	if (dib) {
		// try to guess the file format from the file extension
		fif = FreeImage_GetFIFFromFilename(lpszPathName.c_str());
		if (fif != FIF_UNKNOWN) {
			// check that the plugin has sufficient writing and export capabilities ...
			if (FreeImage_FIFSupportsWriting(fif) && FreeImage_FIFSupportsExportType(fif, FreeImage_GetImageType(dib.get()))) {
				// ok, we can save the file
				bSuccess = FreeImage_Save(fif, dib.get(), lpszPathName.c_str(), flag);
				// unless an abnormal bug, we are done !
			}
			else {
				std::cout << "Can't save file" << lpszPathName << std::endl;
			}
		}
    else {
      std::cerr << "Can't determine output file type" << std::endl;
    }
	}
	return (bSuccess == TRUE);
}
开发者ID:imapp-pl,项目名称:gnr-taskcollector,代码行数:32,代码来源:TaskCollector.cpp


示例11: FreeImage_Allocate

bool ZitexConverter::convert(const QString & inFileName, const ConfigDao & configuration)
{
   auto inFileNameStdStr = inFileName.toStdString();

   Zitex::Reader reader;
   Zitex::Reader::Data data;

   reader.readFromFile(inFileNameStdStr, data);

   for (uint32_t it = 0; it < data.header->texImagesNum; ++it)
   {
      Zitex::TexImageHeader * texImageHeader = data.texImages[it].header;

      if (texImageHeader->level == 0)
      {
         auto width = texImageHeader->width;
         auto height = texImageHeader->height;

         FIBITMAP * fiBitmap = FreeImage_Allocate(width, height, 32);

         squish::DecompressImage(FreeImage_GetBits(fiBitmap), width, height, data.texImages[it].data,
                                 data.header->squishFlags);

         // section(".", 0, -2) copyes from begin to 2nd section from end.
         // The first section from end is the extension

         std::string outFileNameStdStr = inFileName.section(".", 0, -2).append(".png").toStdString();

         FreeImage_FlipVertical(fiBitmap);
         FreeImage_Save(FIF_PNG, fiBitmap, outFileNameStdStr.c_str());

         FreeImage_Unload(fiBitmap);
      }
   }
}
开发者ID:patrykbajos,项目名称:zinot-project,代码行数:35,代码来源:ZitexConverter.cpp


示例12: FreeImage_GetFIFFromFilename

bool RGBAImage::WriteToFile(const char* filename)
{
	const FREE_IMAGE_FORMAT fileType = FreeImage_GetFIFFromFilename(filename);
	if(FIF_UNKNOWN == fileType)
	{
		printf("Can't save to unknown filetype %s\n", filename);
		return false;
	}

	FIBITMAP* bitmap = FreeImage_Allocate(Width, Height, 32, 0x000000ff, 0x0000ff00, 0x00ff0000);
	if(!bitmap)
	{
		printf("Failed to create freeimage for %s\n", filename);
		return false;
	}

	const unsigned int* source = Data;
	for( int y=0; y < Height; y++, source += Width )
	{
		unsigned int* scanline = (unsigned int*)FreeImage_GetScanLine(bitmap, Height - y - 1 );
		memcpy(scanline, source, sizeof(source[0]) * Width);
	}

	FreeImage_SetTransparent(bitmap, true);
	FIBITMAP* converted = FreeImage_ConvertTo24Bits(bitmap);


	const bool result = !!FreeImage_Save(fileType, converted, filename);
	if(!result)
		printf("Failed to save to %s\n", filename);

	FreeImage_Unload(converted);
	FreeImage_Unload(bitmap);
	return result;
}
开发者ID:shakyShane,项目名称:p-diff,代码行数:35,代码来源:RGBAImage.cpp


示例13: SaveTextureToFile

bool SaveTextureToFile(const char* filename, const void* data,  int w, int h)
{
	bool ret = false;
	FIBITMAP* bitmap = nullptr;

	bitmap = FreeImage_AllocateT(FIT_BITMAP, w, h, 32);
	CHECK(bitmap);

	RGBQUAD dst;
	const Color* imageData = (const Color*)data;
	for (int y = 0; y < h; ++y)
	{
		for (int x = 0; x < w; ++x)
		{
			const Color& src = imageData[((h - 1 - y) * w + x)];
			dst.rgbBlue = (BYTE)(src.b * 255);
			dst.rgbGreen = (BYTE)(src.g * 255);
			dst.rgbRed = (BYTE)(src.r * 255);
			dst.rgbReserved = 255;
			CHECK(FreeImage_SetPixelColor(bitmap, x, y, &dst));
		}
	}

	CHECK(FreeImage_Save(FIF_BMP, bitmap, filename, BMP_DEFAULT));

	ret = true;
Exit0:
	if (bitmap)
		FreeImage_Unload(bitmap);
	return ret;
}
开发者ID:marinedzl,项目名称:SakuraEngine,代码行数:31,代码来源:ImageData.cpp


示例14: FreeImage_Initialise

void Film::output(string path){
  int maxIntensity = 255;
  int bpp = 24;
  RGBQUAD color;
  FreeImage_Initialise();
  FIBITMAP* bitmap = FreeImage_Allocate(sceneWidth,
					sceneHeight,
					bpp);
  for(int h = 0; h < sceneHeight; h++){
    vector<Color> row = pixelData[h];
    for(int w = 0; w < sceneWidth; w++){
      Color pixelColor = row[w];
      color.rgbRed = pixelColor.getR() * maxIntensity;
      color.rgbGreen = pixelColor.getG() * maxIntensity;
      color.rgbBlue = pixelColor.getB() * maxIntensity;
      FreeImage_SetPixelColor(bitmap, w, h, &color);
    }
  }
  if (FreeImage_Save(FIF_PNG, bitmap, path.c_str(), 0)) {
    cout << "Image saved to " << path << endl;
    cout << sceneWidth << endl;
  }
  else {
    cerr << "Couldn't save image to " << path << endl;
    exit(1);
  }

  FreeImage_DeInitialise();
}
开发者ID:sebanie,项目名称:tracingrays,代码行数:29,代码来源:Film.cpp


示例15: FreeImage_Initialise

void pre_lzw::do_lzw(const QDir & d){
    FreeImage_Initialise(true);
    QString label_out = "";
    QString dst = ui.lineEdit_2->text();
    QString d_src = d.path();
    QString serial_str = d_src.right(5);
    QDir dst_dir(dst);
    dst_dir.mkdir(serial_str);
    QString image_name = "", image_name_path(""), saved_name("");
    int dot_pos = 0;
    QFileInfoList handled_images = d.entryInfoList();
    QList<QFileInfo>::iterator images_iter = handled_images.begin();
    
    FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
    for(; images_iter < handled_images.end(); ++images_iter){
        image_name_path = (*images_iter).absoluteFilePath();
        if((*images_iter).isDir()){
            continue;
        }
        FIBITMAP *handled_image = 0;
        image_name = (*images_iter).fileName();
        dot_pos = image_name.indexOf(".");
        saved_name = dst + "\\" + serial_str + "\\" + image_name.left(dot_pos) + "_c.tif";
        label_out += saved_name + "\n";
        fif = FreeImage_GetFileType(image_name_path.toStdString().c_str());
        handled_image = FreeImage_Load(fif, image_name_path.toStdString().c_str());
        FreeImage_Save(FIF_TIFF, handled_image, saved_name.toStdString().c_str(), TIFF_LZW);
        FreeImage_Unload(handled_image);
    }
//    ui.label->setText(label_out);
    FreeImage_DeInitialise();

}
开发者ID:sulei1324,项目名称:lab_codes,代码行数:33,代码来源:pre_lzw.cpp


示例16: testLoadMemIO

/**
Test loading from a buffer attached to a memory stream
*/
void testLoadMemIO(const char *lpszPathName) {
	struct stat buf;
	int result;

	// get data associated with lpszPathName
	result = stat(lpszPathName, &buf);
	if(result == 0) {
		// allocate a memory buffer and load temporary data
		BYTE *mem_buffer = (BYTE*)malloc(buf.st_size * sizeof(BYTE));
		if(mem_buffer) {
			FILE *stream = fopen(lpszPathName, "rb");
			if(stream) {
				fread(mem_buffer, sizeof(BYTE), buf.st_size, stream);
				fclose(stream);

				// attach the binary data to a memory stream
				fipMemoryIO memIO(mem_buffer, buf.st_size);

				// get the file type
				FREE_IMAGE_FORMAT fif = memIO.getFileType();

				// load an image from the memory stream
				FIBITMAP *check = memIO.read(fif, PNG_DEFAULT);

				// save as a regular file
				FreeImage_Save(FIF_PNG, check, "blob.png", PNG_DEFAULT);
				
				// close the stream (memIO is destroyed)
			}

			// user is responsible for freeing the data
			free(mem_buffer);
		}
	}
}
开发者ID:MichaelH13,项目名称:sdkpub,代码行数:38,代码来源:fipTestMemIO.cpp


示例17: ofSaveImage

//----------------------------------------------------------------
void ofSaveImage(ofPixels & pix, string fileName, ofImageQualityType qualityLevel) {

	if (pix.isAllocated() == false){
		ofLog(OF_LOG_ERROR,"error saving image - pixels aren't allocated");
		return;
	}

	#ifdef TARGET_LITTLE_ENDIAN
		pix.swapRgb();
	#endif

	FIBITMAP * bmp	= getBmpFromPixels(pix);

	#ifdef TARGET_LITTLE_ENDIAN
		pix.swapRgb();
	#endif
	
	fileName = ofToDataPath(fileName);
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	fif = FreeImage_GetFileType(fileName.c_str(), 0);
	if(fif == FIF_UNKNOWN) {
		// or guess via filename
		fif = FreeImage_GetFIFFromFilename(fileName.c_str());
	}
	if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
		if(fif == FIF_JPEG) {
			int quality = JPEG_QUALITYSUPERB;
			switch(qualityLevel) {
				case OF_IMAGE_QUALITY_WORST: quality = JPEG_QUALITYBAD; break;
				case OF_IMAGE_QUALITY_LOW: quality = JPEG_QUALITYAVERAGE; break;
				case OF_IMAGE_QUALITY_MEDIUM: quality = JPEG_QUALITYNORMAL; break;
				case OF_IMAGE_QUALITY_HIGH: quality = JPEG_QUALITYGOOD; break;
				case OF_IMAGE_QUALITY_BEST: quality = JPEG_QUALITYSUPERB; break;
			}
			FreeImage_Save(fif, bmp, fileName.c_str(), quality);
		} else {
			if(qualityLevel != OF_IMAGE_QUALITY_BEST) {
				ofLog(OF_LOG_WARNING, "ofImageCompressionType only applies to JPEG images, ignoring value.");
			}
			FreeImage_Save(fif, bmp, fileName.c_str());
		}
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
}
开发者ID:alfredoBorboa,项目名称:openFrameworks,代码行数:48,代码来源:ofImage.cpp


示例18: FreeImage_GetFIFFromFilename

void rtgu::image_io::write_image(char const* filename, any_image const& image)
{
  FREE_IMAGE_FORMAT fi_image_format = FreeImage_GetFIFFromFilename(filename);

  FIBITMAP* fi_image = detail::get_FIBITMAP(image);

  BOOL result = FreeImage_Save(fi_image_format, fi_image, filename);
}
开发者ID:rotoglup,项目名称:rotoglup-scratchpad,代码行数:8,代码来源:image_io.hpp


示例19: encode

    //---------------------------------------------------------------------
    void FreeImageCodec::codeToFile(MemoryDataStreamPtr& input,
        const String& outFileName, Codec::CodecDataPtr& pData) const
    {
        FIBITMAP* fiBitmap = encode(input, pData);

        FreeImage_Save((FREE_IMAGE_FORMAT)mFreeImageType, fiBitmap, outFileName.c_str());
        FreeImage_Unload(fiBitmap);
    }
开发者ID:Kanma,项目名称:Ogre,代码行数:9,代码来源:OgreFreeImageCodec.cpp


示例20: FreeImage_Save

void ImagePNG::save(std::string name)
{
	std::string filename = name+".png";
	if(bitmap != nullptr)
	{
		FreeImage_Save(FIF_PNG,bitmap,filename.c_str(),0);
	}
}
开发者ID:buleks,项目名称:mpims_converter,代码行数:8,代码来源:ImagePNG.cpp



注:本文中的FreeImage_Save函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FreeImage_Unload函数代码示例发布时间:2022-05-30
下一篇:
C++ FreeImage_OutputMessageProc函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap