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

C++ FreeImage_Allocate函数代码示例

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

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



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


示例16: gifcat

FIBITMAP * gifcat(char gifpath[MAXGIFCOUNT][MAXPATHCHAR], unsigned gifPathCount) // 将多张图片连接为一张图片
{
	FIBITMAP * hImageAll ;
	unsigned ImgHeightAll = 0 ;
	FIBITMAP * hImage[MAXGIFCOUNT] ;
	unsigned ImgHeight[MAXGIFCOUNT] ;
	unsigned ImgWidth ;
	RGBQUAD * palSrc ;
	RGBQUAD * palAll ;
	unsigned n , NowYPos = 0 ;
//	---
	for ( n=0; n < gifPathCount; ++n) {
		hImage[n] = FreeImage_Load(FIF_GIF, gifpath[n], 0);
		ImgHeight[n] = FreeImage_GetHeight(hImage[n]) ;
		ImgHeightAll += ImgHeight[n] ;
	}
	ImgWidth = FreeImage_GetWidth(hImage[0]) ;

	hImageAll = FreeImage_Allocate(ImgWidth, ImgHeightAll, 8, 0, 0, 0);  //创建目标图像
	palAll = FreeImage_GetPalette(hImageAll);       // 复制调色板
	palSrc = FreeImage_GetPalette(hImage[0]);
	for (n = 0; n < 256; ++n) {
		palAll[n].rgbRed = palSrc[n].rgbRed ;
		palAll[n].rgbGreen = palSrc[n].rgbGreen ;
		palAll[n].rgbBlue = palSrc[n].rgbBlue ;
	}
	palAll[70].rgbRed = 255   ;
	palAll[70].rgbGreen = 255 ;
	palAll[70].rgbBlue = 255  ;

	for ( n=0; n < gifPathCount; ++n) {  // 粘贴图像
		FreeImage_Paste(hImageAll, hImage[n], 0, NowYPos, 300) ;
		NowYPos += ImgHeight[n] ;
		FreeImage_Unload(hImage[n]) ;
	}
	return hImageAll ;
}
开发者ID:linpinger,项目名称:foxbook-ahk,代码行数:37,代码来源:imgsplit_V1.8.3.cpp


示例17: GetFrame

    PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env)
    {
        PVideoFrame dst = env->NewVideoFrame(m_targetVideoInfo);
        unsigned char* const dstp = dst->GetWritePtr();

        FIBITMAP *frameImage =
                FreeImage_Allocate(m_targetVideoInfo.width, m_targetVideoInfo.height, 24);
        copyVideoFrameToImage(m_originRgb->GetFrame(n, env), frameImage);

        const int reservedPaletteSize = m_useGlobalPalette ? m_paletteSize : 0;
        FIBITMAP *quantizedFrameImage =
                FreeImage_ColorQuantizeEx(frameImage, FIQ_NNQUANT, m_paletteSize, reservedPaletteSize, m_globalPalette);
        FreeImage_Unload(frameImage);
        FIBITMAP *quantizedFrameImageRgb24 =
                FreeImage_ConvertTo24Bits(quantizedFrameImage);
        FreeImage_Unload(quantizedFrameImage);
        for (int row = 0; row < m_targetVideoInfo.height; ++row) {
            unsigned char* dstrowp = dstp + row * dst->GetPitch();
            const BYTE* const srcp = FreeImage_GetScanLine(quantizedFrameImageRgb24, row);
            memcpy(dstrowp, srcp, dst->GetRowSize());
        }
        FreeImage_Unload(quantizedFrameImageRgb24);
        return dst;
    }
开发者ID:aportale,项目名称:qtorials,代码行数:24,代码来源:colorquantize.cpp


示例18: ColorQuantize

    ColorQuantize(PClip originClip, int paletteSize,
                  bool useGlobalPalette, FREE_IMAGE_QUANTIZE algorithm,
                  const char *globalPaletteOutputFile, IScriptEnvironment* env)
        : m_origin(originClip)
        , m_paletteSize(paletteSize)
        , m_useGlobalPalette(useGlobalPalette)
        , m_algorithm(algorithm)
        , m_targetVideoInfo(originClip->GetVideoInfo())
        , m_globalPalette(0)
    {
        if (!originClip->GetVideoInfo().IsRGB24()) {
            m_originRgb = env->Invoke("ConvertToRgb24", originClip).AsClip();
            m_targetVideoInfo.pixel_type = VideoInfo::CS_BGR24;
        } else {
            m_originRgb = originClip;
        }

        if (m_useGlobalPalette) {
            FIBITMAP *hugeImage =
                    FreeImage_Allocate(m_targetVideoInfo.width,
                                       m_targetVideoInfo.height * m_targetVideoInfo.num_frames,
                                       24);
            for (int frame = 0; frame < m_targetVideoInfo.num_frames; ++frame) {
                const PVideoFrame videoFrame = m_originRgb->GetFrame(frame, env);
                copyVideoFrameToImage(m_originRgb->GetFrame(frame, env),hugeImage, frame * m_targetVideoInfo.height);
            }
            FIBITMAP *quantizedImage =
                    FreeImage_ColorQuantizeEx(hugeImage, algorithm, m_paletteSize);
            FreeImage_Unload(hugeImage);
            m_globalPalette = new RGBQUAD[m_paletteSize];
            memcpy(m_globalPalette, FreeImage_GetPalette(quantizedImage), m_paletteSize * sizeof(RGBQUAD));
            FreeImage_Unload(quantizedImage);
            if (globalPaletteOutputFile)
                savePaletteImage(globalPaletteOutputFile, m_globalPalette, m_paletteSize);
        }
    }
开发者ID:aportale,项目名称:qtorials,代码行数:36,代码来源:colorquantize.cpp


示例19: saveImage

 // Save a gray-scale image to disk.
 void 
 saveImage(const std::string & rFileName, const ImageCPU_8u_C1 & rImage)
 {
             // create the result image storage using FreeImage so we can easily 
             // save
     FIBITMAP * pResultBitmap = FreeImage_Allocate(rImage.width(), rImage.height(), 8 /* bits per pixel */);
     NPP_ASSERT_NOT_NULL(pResultBitmap);
     unsigned int nDstPitch   = FreeImage_GetPitch(pResultBitmap);
     Npp8u * pDstLine = FreeImage_GetBits(pResultBitmap) + nDstPitch * (rImage.height()-1);
     const Npp8u * pSrcLine = rImage.data();
     unsigned int nSrcPitch = rImage.pitch();
     
     for (size_t iLine = 0; iLine < rImage.height(); ++iLine)
     {
         memcpy(pDstLine, pSrcLine, rImage.width() * sizeof(Npp8u));
         pSrcLine += nSrcPitch;
         pDstLine -= nDstPitch;
     }
         
             // now save the result image
     bool bSuccess;
     bSuccess = FreeImage_Save(FIF_PGM, pResultBitmap, rFileName.c_str(), 0) == TRUE;
     NPP_ASSERT_MSG(bSuccess, "Failed to save result image.");
 }
开发者ID:D2LSystem,项目名称:GPU-Computing-SDK-4.2.9,代码行数:25,代码来源:ImageIO.cpp


示例20: ClampConvertRGBFTo24

/**
Clamp RGBF image highest values to display white, 
then convert to 24-bit RGB
*/
FIBITMAP* 
ClampConvertRGBFTo24(FIBITMAP *src) {
	if(FreeImage_GetImageType(src) != FIT_RGBF)
		return FALSE;

	unsigned width  = FreeImage_GetWidth(src);
	unsigned height = FreeImage_GetHeight(src);

	FIBITMAP *dst = FreeImage_Allocate(width, height, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
	if(!dst) return NULL;

	unsigned src_pitch  = FreeImage_GetPitch(src);
	unsigned dst_pitch  = FreeImage_GetPitch(dst);

	BYTE *src_bits = (BYTE*)FreeImage_GetBits(src);
	BYTE *dst_bits = (BYTE*)FreeImage_GetBits(dst);

	for(unsigned y = 0; y < height; y++) {
		const FIRGBF *src_pixel = (FIRGBF*)src_bits;
		BYTE *dst_pixel = (BYTE*)dst_bits;
		for(unsigned x = 0; x < width; x++) {
			const float red   = (src_pixel[x].red > 1)   ? 1 : src_pixel[x].red;
			const float green = (src_pixel[x].green > 1) ? 1 : src_pixel[x].green;
			const float blue  = (src_pixel[x].blue > 1)  ? 1 : src_pixel[x].blue;
			
			dst_pixel[FI_RGBA_RED]   = (BYTE)(255 * red   + 0.5);
			dst_pixel[FI_RGBA_GREEN] = (BYTE)(255 * green + 0.5);
			dst_pixel[FI_RGBA_BLUE]  = (BYTE)(255 * blue  + 0.5);
			dst_pixel += 3;
		}
		src_bits += src_pitch;
		dst_bits += dst_pitch;
	}

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FreeImage_ConvertTo32Bits函数代码示例发布时间:2022-05-30
下一篇:
C++ FreeFile函数代码示例发布时间: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