这篇教程C++ FreeImage_Allocate函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FreeImage_Allocate函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeImage_Allocate函数的具体用法?C++ FreeImage_Allocate怎么用?C++ FreeImage_Allocate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FreeImage_Allocate函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,
示例2: TestFIA_DrawImageDstRectTest4static voidTestFIA_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,
示例3: FreeImage_Allocatestatic 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,
示例4: FreeImage_AllocateBOOL 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,
示例5: vpvoid 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,
示例6: SaveImagebool 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,
示例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,
示例8: TestFIA_Index1PixelLineTeststatic voidTestFIA_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,
示例9: to_free_imagestatic 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,
示例10: GetObjectstatic 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,
示例11: mainint 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,
示例12: FreeImage_GetFIFFromFilenamebool 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,
示例13: TestFIA_DrawImageTest12static voidTestFIA_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,
示例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 C++ FreeImage_ConvertTo32Bits函数代码示例 C++ FreeFile函数代码示例
|