当前位置: 首页>>代码示例>>C++>>正文


C++ FreeImage_Allocate函数代码示例

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


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

示例1: FreeImage_Allocate

    void PImage::save(const char * out) {
        FIBITMAP *bitmap = FreeImage_Allocate(width, height, 24);
        RGBQUAD c;
        if (!bitmap) exit(1);

        for(int y=0; y<height; y++) {
            for(int x=0; x<width; x++) {
                c.rgbRed    = texturebuffer[(((y*width)+x)*4)+0];
                c.rgbGreen  = texturebuffer[(((y*width)+x)*4)+1];
                c.rgbBlue   = texturebuffer[(((y*width)+x)*4)+2];
                FreeImage_SetPixelColor(bitmap, x, y, &c);
            }
        }

        FreeImage_Save(FIF_PNG, bitmap, out, 0);
        FreeImage_Unload(bitmap);
    }
开发者ID:TLeaves,项目名称:cprocessing,代码行数:17,代码来源:pimage.cpp

示例2: TestFIA_DrawImageDstRectTest4

static void
TestFIA_DrawImageDstRectTest4(CuTest* tc)
{
  const char *file = TEST_DATA_DIR "fly.bmp";

  FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

  CuAssertTrue(tc, dib1 != NULL);

  FIBITMAP *dib2 = FreeImage_ConvertTo32Bits(dib1);
  
  CuAssertTrue(tc, dib2 != NULL);
  
  FIBITMAP *dst = FreeImage_Allocate(790,582, 32, 0, 0, 0);
   
  FIA_DrawColourSolidRect(dst, MakeFIARect(0,0, FreeImage_GetWidth(dst) - 1,
                                                FreeImage_GetHeight(dst) - 1), FIA_RGBQUAD(255,255,0));

  CuAssertTrue(tc, dst != NULL);
   
  FIA_Matrix *matrix = FIA_MatrixNew();

  FIA_MatrixScale(matrix, 2.0, 2.0, FIA_MatrixOrderPrepend);
  
  int err = FIA_DrawImageToDst(dst, dib2, matrix, 0,0,350/2,271/2, FIA_RGBQUAD(128,128,128), 1);

  CuAssertTrue(tc, err != FIA_ERROR);

  FIA_MatrixTranslate(matrix, 100, 100, FIA_MatrixOrderPrepend);
  FIA_MatrixRotate(matrix, 45.0, FIA_MatrixOrderPrepend);

  err = FIA_DrawImageToDst(dst, dib2, matrix, 0,0,350/2,271/2, FIA_RGBQUAD(128,128,128), 1);

  CuAssertTrue(tc, err != FIA_ERROR);
  
  FIA_MatrixDestroy(matrix);
  
  CuAssertTrue(tc, dst != NULL);

  FIA_SaveFIBToFile(dst, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_DrawImageDstRectTest4.bmp", BIT24);

  FreeImage_Unload(dib1);
  FreeImage_Unload(dib2);
  FreeImage_Unload(dst);
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:45,代码来源:FreeImageAlgorithms_DrawingTests.cpp

示例3: FreeImage_Allocate

static FIBITMAP *ToFreeImage(const RGBAImage &image)
{
	const unsigned int *data = image.Get_Data();

	FIBITMAP* bitmap = FreeImage_Allocate(
		image.Get_Width(), image.Get_Height(), 32,
		0x000000ff, 0x0000ff00, 0x00ff0000);
	assert(bitmap);

	for (int y=0; y < image.Get_Height(); y++, data += image.Get_Width())
	{
		unsigned int* scanline = reinterpret_cast<unsigned int*>(FreeImage_GetScanLine(
			bitmap, image.Get_Height() - y - 1));
		memcpy(scanline, data, sizeof(data[0]) * image.Get_Width());
	}

	return bitmap;
}
开发者ID:AndrewShalimov,项目名称:perceptualdiff,代码行数:18,代码来源:RGBAImage.cpp

示例4: FreeImage_Allocate

BOOL fipImage::combineChannels(fipImage& red, fipImage& green, fipImage& blue) {
	if(!_dib) {
		int width = red.getWidth();
		int height = red.getHeight();
		_dib = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
	}

	if(_dib) {
		BOOL bResult = TRUE;
		bResult &= FreeImage_SetChannel(_dib, red._dib, FICC_RED);
		bResult &= FreeImage_SetChannel(_dib, green._dib, FICC_GREEN);
		bResult &= FreeImage_SetChannel(_dib, blue._dib, FICC_BLUE);

		_bHasChanged = TRUE;

		return bResult;
	}
	return FALSE;
}
开发者ID:MrMasterplan,项目名称:PIC-stuff,代码行数:19,代码来源:fipImage.cpp

示例5: vp

void Fisheye::render_scene(World& w) {
	RGBColor L;
	ViewPlane vp(w.vp);
	FreeImage_Initialise();
	FIBITMAP* bitmap = FreeImage_Allocate(vp.hres, vp.vres, 24);
	RGBQUAD color;
	int hres = vp.hres;
	int vres = vp.vres;
	float s = vp.s;
	Ray ray;
	int depth = 0;
	Point2D sp;
	Point2D pp;
	float r_squared;

	ray.o  = eye;

	for(int r = 0; r < vres; r++)
		for(int c = 0; c < hres; c++) {
			L = black;

			for(int j = 0; j < vp.num_samples; j++) {
				sp = vp.sampler_ptr -> sample_unit_square();
				pp.x = s * (c - hres / 2.0 + sp.x);
				pp.y = s * (r - vres / 2.0 + sp.y);
				ray.d = ray_direction(pp, hres, vres, s, r_squared);

				if(r_squared <= 1.0)
					L += w.tracer_ptr -> trace_ray(ray);
			}

			L /= vp.num_samples;
			L *= exposure_time;
			w.display_pixel(r, c, L);
			color.rgbRed = (int)(L.r*255);
			color.rgbGreen = (int)(L.g*255);
			color.rgbBlue = (int)(L.b*255);
			FreeImage_SetPixelColor(bitmap, c, r, &color);
		}
	if (FreeImage_Save(FIF_PNG, bitmap, "test.png", 0))
		std::cout << "Image Successfully Saved!" << std::endl;
	FreeImage_DeInitialise();
}
开发者ID:elendorial,项目名称:RayTracer,代码行数:43,代码来源:Fisheye.cpp

示例6: SaveImage

bool SaveImage(Graphics::TBitmap* picture, AnsiString path, TYPE bit_per_pixel, int flags)
{
	FIBITMAP *image = FreeImage_Allocate(picture->Width, picture->Height, 32);
	if(!image) return false;
	
	picture->PixelFormat = pf32bit;
	
	if(!WriteImage(image, picture))
	{
		FreeImage_Unload(image);
		return false;
	}

	AnsiString ext((((AnsiString)ExtractFileExt(path))).UpperCase());

	if (ext == ".BMP")
	{
		if(FreeImage_Save(FIF_BMP, BitrateConversion(image,bit_per_pixel), path.c_str(), BMP_DEFAULT))
		{
			FreeImage_Unload(image);
			return true;
		}	
	}	
	else if (ext == ".JPG")
	{
		if(FreeImage_Save(FIF_JPEG, FreeImage_ConvertTo24Bits(image), path.c_str(), flags))
		{
			FreeImage_Unload(image);
			return true;
		}
	}		
	else if (ext == ".TIF")
	{
		if(FreeImage_Save(FIF_TIFF, FreeImage_ConvertTo24Bits(image), path.c_str(), TIFF_DEFAULT))
		{
			FreeImage_Unload(image);
			return true;
		}	
	}
		
	FreeImage_Unload(image);
	return false;
}
开发者ID:ClockMan,项目名称:edytorgraficzny,代码行数:43,代码来源:SaveImage.cpp

示例7: FreeImage_GetPitch

// Gets a new FreeImage bitmap if we haven't got one yet or the current one is too small.
// On entry the background thread must not be scanning the bitmap - eg waiting.
// The parameter 'clear' is the value to clear the bitmap to - effectively clears to
// a grey of colour RGB(clear, clear, clear), or -1 to not clear.
void CHexEditDoc::GetAerialBitmap(int clear /*= 0xC0*/)
{
    // If we already have a bitmap make sure it is big enough
    if (dib_ != NULL)
    {
        int dib_size = FreeImage_GetPitch(dib_) * FreeImage_GetHeight(dib_);
        int dib_rows = int(length_/bpe_/MAX_WIDTH) + 2;
        if (dib_size >= MAX_WIDTH*dib_rows*3)
        {
            if (clear > -1)
                memset(FreeImage_GetBits(dib_), clear, dib_size);
            return;
        }

        // Not big enough so free it and reallocate (below)
        FIBITMAP *dib = dib_;
        dib_ = NULL;
        TRACE("+++ FreeImage_Unload(%d)\n", dib);
        FreeImage_Unload(dib);
        if (clear <= -1)
            clear = 0xC0;  // if we get a new bitmap we must clear it
    }

    // TBD: TODO we need user options for default bpe and MAX_BMP (min 16Mb = 1 TByte file @ BPE 65536)
    bpe_ = 1;

    // Keep increasing bpe_ by powers of two until we get a small enough bitmap
    while (bpe_ <= 65536 && (length_*3)/bpe_ > theApp.aerial_max_)
        bpe_ = bpe_<<1;

    // Work out the number of bitmap rows we would need at the widest bitmap size
    int rows = int(length_/bpe_/MAX_WIDTH) + 2;    // Round up to next row plus add one more row to allow for "reshaping"
    ASSERT((rows-2)*MAX_WIDTH < theApp.aerial_max_);

    dib_ = FreeImage_Allocate(MAX_WIDTH, rows, 24);

    dib_size_ = MAX_WIDTH*rows*3;           // DIB size in bytes since we have 3 bytes per pixel and no pad bytes at the end of each scan line
    ASSERT(dib_size_ == FreeImage_GetPitch(dib_) * FreeImage_GetHeight(dib_));
    TRACE("+++ FreeImage_Allocate %d at %p end %p\n", dib_, FreeImage_GetBits(dib_), FreeImage_GetBits(dib_)+dib_size_);
    if (clear > -1)
        memset(FreeImage_GetBits(dib_), clear, dib_size_);       // Clear to a grey
}
开发者ID:AndrewWPhillips,项目名称:HexEdit,代码行数:46,代码来源:BGAerial.cpp

示例8: TestFIA_Index1PixelLineTest

static void
TestFIA_Index1PixelLineTest(CuTest* tc)
{
        FIBITMAP *src = FreeImage_Allocate(500,500, 8, 0, 0, 0);

        CuAssertTrue(tc, src != NULL);

        FIAPOINT p1, p2, p3;

        p1.x = 10;
        p1.y = 10;
        p2.x = 200;
        p2.y = 300;

		FIA_DrawOnePixelIndexLineFromTopLeft (src, p1, p2, 255);

        FIA_SimpleSaveFIBToFile(src, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_Index1PixelLineTest.bmp");

        FreeImage_Unload(src);
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:20,代码来源:FreeImageAlgorithms_DrawingTests.cpp

示例9: to_free_image

static std::shared_ptr<FIBITMAP> to_free_image(const RGBAImage &image)
{
    const auto *data = image.get_data();

    std::shared_ptr<FIBITMAP> bitmap(
        FreeImage_Allocate(image.get_width(), image.get_height(), 32,
                           0x000000ff, 0x0000ff00, 0x00ff0000),
        FreeImageDeleter());
    assert(bitmap.get());

    for (auto y = 0u; y < image.get_height();
         y++, data += image.get_width())
    {
        auto scanline = reinterpret_cast<unsigned int *>(
            FreeImage_GetScanLine(bitmap.get(), image.get_height() - y - 1));
        memcpy(scanline, data, sizeof(data[0]) * image.get_width());
    }

    return bitmap;
}
开发者ID:ivokabel,项目名称:perceptualdiff,代码行数:20,代码来源:rgba_image.cpp

示例10: GetObject

static FIBITMAP *FreeImage_CreateDIBFromHBITMAP(HBITMAP hBmp)
{
	BITMAP bm;

	if(hBmp) {
		GetObject(hBmp, sizeof(BITMAP), (LPSTR) &bm);
		FIBITMAP *dib = FreeImage_Allocate(bm.bmWidth, bm.bmHeight, bm.bmBitsPixel,0,0,0);
		// The GetDIBits function clears the biClrUsed and biClrImportant BITMAPINFO members (dont't know why)
		// So we save these infos below. This is needed for palettized images only.
		int nColors = FreeImage_GetColorsUsed(dib);
		HDC dc = GetDC(NULL);
		int Success = GetDIBits(dc, hBmp, 0, FreeImage_GetHeight(dib),
			FreeImage_GetBits(dib), FreeImage_GetInfo(dib), DIB_RGB_COLORS);
		ReleaseDC(NULL, dc);
		// restore BITMAPINFO members
		FreeImage_GetInfoHeader(dib)->biClrUsed = nColors;
		FreeImage_GetInfoHeader(dib)->biClrImportant = nColors;
		return dib;
	}
	return NULL;
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:21,代码来源:main.cpp

示例11: main

int main(int argc, char *argv[])
{
	if (argc != 3)
	{
		printf("Usage : cworld2img input_filename.bin output_filename.png\n\n");
		return 0;
	}
	FreeImage_Initialise();
	FIBITMAP *bitmap = FreeImage_Allocate(WORLD_WIDTH, WORLD_HEIGHT, 32);
	if(!bitmap)
	{
		printf("Error while allocating image. Aborting");
		return -1;
	}
	FILE *fd = fopen(argv[1], "rb");
	fread(c_world.solids, sizeof(block), WORLD_HEIGHT * WORLD_WIDTH, fd);
	fclose(fd);
	for(int i = 0; i < WORLD_HEIGHT; i++)
	{
		for(int j = 0; j < WORLD_WIDTH; j++)
		{
			switch(c_world.solids[WORLD_WIDTH * i + j])
			{
			case BLCK_AIR:
				FreeImage_SetPixelColor(bitmap, j, WORLD_HEIGHT - i, &qpixel_air);break;
			case BLCK_DIRT:
				FreeImage_SetPixelColor(bitmap, j, WORLD_HEIGHT - i, &qpixel_dirt);break;
			default:
				FreeImage_SetPixelColor(bitmap, j, WORLD_HEIGHT - i, &qpixel_unknown);break;
			}
		}
	}
	if(!FreeImage_Save(FIF_PNG, bitmap, argv[2], 0))
	{
		printf("Error while saving image. Aborting");
		return -1;
	}
	FreeImage_DeInitialise();
	return 0;
}
开发者ID:omegacoleman,项目名称:cworld2img,代码行数:40,代码来源:cworld2img.cpp

示例12: FreeImage_GetFIFFromFilename

bool tpImageIO::write(const tpImageGray& I, const char* filename)
{
	
	// On essaye de trouver l'extension
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	fif = FreeImage_GetFIFFromFilename(filename);

	if(fif == FIF_UNKNOWN)
	{
		std::cerr << "[Error] [tpImageIO] Write : Unknown file format !" << std::endl;
		return false;
	}

	unsigned width = I.getWidth();
	unsigned height = I.getHeight();

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

	unsigned pitch = FreeImage_GetPitch(dib);

	BYTE *bits = (BYTE*)FreeImage_GetBits(dib);
	for(unsigned int y = 0; y < height; y++) {
		BYTE *pixel = (BYTE*)bits;
		for(unsigned int x = 0; x < width; x++) {
			//std::cout << "[DEBUG] (" << y << "," << x << ") " << (int)I[y][x] << std::endl;
			pixel[FI_RGBA_RED] = I[y][x];
			pixel[FI_RGBA_GREEN] = I[y][x];
			pixel[FI_RGBA_BLUE] = I[y][x];
			pixel[FI_RGBA_ALPHA] = 255;
			pixel += 4;
		} // next line
		bits += pitch;
	}

	FreeImage_Save (fif, dib, filename, 0);

	FreeImage_Unload(dib);

	return true;
}
开发者ID:beltegeuse,项目名称:HDRComposer,代码行数:40,代码来源:tpImageIO.cpp

示例13: TestFIA_DrawImageTest12

static void
TestFIA_DrawImageTest12(CuTest* tc)
{
  const char *file = TEST_DATA_DIR "fly.bmp";

  FIBITMAP *dib1 = FIA_LoadFIBFromFile(file);

  CuAssertTrue(tc, dib1 != NULL);

  FIBITMAP *dib2 = FreeImage_ConvertTo32Bits(dib1);
  
  CuAssertTrue(tc, dib2 != NULL);
  
  FIBITMAP *dst = FreeImage_Allocate(790,582, 32, 0, 0, 0);
   
  CuAssertTrue(tc, dst != NULL);
   
  FIA_Matrix *matrix = FIA_MatrixNew();

  FIA_MatrixScale(matrix, 2.0, 2.0, FIA_MatrixOrderPrepend);
  FIA_MatrixTranslate(matrix, 100, 100, FIA_MatrixOrderPrepend);
  FIA_MatrixRotate(matrix, 45.0, FIA_MatrixOrderPrepend);

  
   int err = FIA_DrawImageFromSrcToDst(dst, dib2, matrix, 
                            0,0,350,271/2,
                            150,40,350/2,271/2, FIA_RGBQUAD(128,128,128), 0);

  CuAssertTrue(tc, err != FIA_ERROR);
  
  FIA_MatrixDestroy(matrix);
  
  CuAssertTrue(tc, dst != NULL);

  FIA_SaveFIBToFile(dst, TEST_DATA_OUTPUT_DIR "Drawing/TestFIA_DrawImageTest12.bmp", BIT24);

  FreeImage_Unload(dib1);
  FreeImage_Unload(dib2);
  FreeImage_Unload(dst);
}
开发者ID:atdgroup,项目名称:FreeImageAlgorithms,代码行数:40,代码来源:FreeImageAlgorithms_DrawingTests.cpp

示例14: createZonePlateImage

/** Create a Zone Plate test pattern.

  The circular zone plate has zero horizontal and vertical frequencies at the center. 
  Horizontal frequencies increase as you move horizontally, and vertical frequencies increase as you move vertically.
  These patterns are useful to:
  <ul>
  <li> evaluate image compression 
  <li> evaluate filter properties 
  <li> evaluate the quality of resampling algorithms 
  <li> adjust gamma correction - at the proper gamma setting, the møires should be minimized 
  </ul>
  Reference: 
  [1] Ken Turkowski, Open Source Repository. [Online] http://www.worldserver.com/turk/opensource/
*/
FIBITMAP* createZonePlateImage(unsigned width, unsigned height, int scale) {
	const double PI = 3.1415926535898;
	BYTE sinTab[256];

	FIBITMAP *dst;
	int i, j, x, y;
	int cX, cY, d;

	// allocate a 8-bit dib
	dst = FreeImage_Allocate(width, height, 8);
	if(!dst)
		return NULL;

	// build a greyscale palette
	RGBQUAD *pal = FreeImage_GetPalette(dst);
	for(i = 0; i < 256; i++) {
		pal[i].rgbRed = i;
		pal[i].rgbGreen = i;
		pal[i].rgbBlue = i;
	}

	// build the sinus table
	for(i = 0; i < 256; i++) {
		sinTab[i] = (BYTE)(127.5 * sin(PI * (i - 127.5) / 127.5) + 127.5);
	}

	cX = width / 2;
	cY = height / 2;
	
	// create a zone plate
	for(i = height, y = -cY; i--; y++) {
		BYTE *dst_bits = FreeImage_GetScanLine(dst, i);
		for (j = width, x = -cX; j--; x++) {
			d = ((x * x + y * y) * scale) >> 8;
			dst_bits[j] = sinTab[d & 0xFF];
		}
	}

	return dst;
}
开发者ID:BackupTheBerlios,项目名称:mimplugins-svn,代码行数:54,代码来源:testTools.cpp

示例15: send

	virtual bool send(const safe_ptr<core::read_frame>& frame) override
	{				
		auto format_desc = format_desc_;
		boost::thread async([format_desc, frame]
		{
			try
			{
				auto filename = narrow(env::data_folder()) +  boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time()) + ".png";

				auto bitmap = std::shared_ptr<FIBITMAP>(FreeImage_Allocate(format_desc.width, format_desc.height, 32), FreeImage_Unload);
				memcpy(FreeImage_GetBits(bitmap.get()), frame->image_data().begin(), frame->image_size());
				FreeImage_FlipVertical(bitmap.get());
				FreeImage_Save(FIF_PNG, bitmap.get(), filename.c_str(), 0);
			}
			catch(...)
			{
				CASPAR_LOG_CURRENT_EXCEPTION();
			}
		});
		async.detach();

		return false;
	}
开发者ID:Mistobaan,项目名称:CasparCG,代码行数:23,代码来源:image_consumer.cpp


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