void GlScreenshot( int w, int h, const char *filename ) { // grab pixels from the screen float *buffer = (float*)malloc( 3*w*h*sizeof(float)); ImgColor *img = new ImgColor( w, h ); glReadPixels( 0, 0, w, h, GL_RGB, GL_FLOAT, buffer); // multiply by 255 and flip vertically (OpenGL origin is lower left) int i,j; for (i=0;i<h;i++) { for (j=0;j<w;j++) { img->SetPixel( j, i, (unsigned char)(255*buffer[3*(w*(h-1-i)+j)]), (unsigned char)(255*buffer[3*(w*(h-1-i)+j)+1]), (unsigned char)(255*buffer[3*(w*(h-1-i)+j)+2]) ); } } // save image char ext[5]; GetFileExtension( filename, ext ); if ( strncmp(ext,"jpg",3) == 0 ) SaveImage( img, filename, EXT_JPG ); if ( strncmp(ext,"png",3) == 0 ) SaveImage( img, filename, EXT_PNG ); free( buffer ); }
void PNGTests::testWriter() { static const int width = 256; static const int height = 256; // create an image and fill it with random data auto_ptr<Image> image(CreateImage(width, height, PF_R8G8B8A8)); setRandomBytes((byte*)image->getPixels(), width * height * 4); // generate filename char* filename = tmpnam(0); CPPUNIT_ASSERT_MESSAGE("opening temporary file", filename != 0); // save image CPPUNIT_ASSERT(SaveImage(filename, FF_PNG, image.get()) == true); // load it back auto_ptr<Image> img2(OpenImage(filename, PF_R8G8B8A8)); CPPUNIT_ASSERT_MESSAGE("reloading image file", img2.get() != 0); AssertImagesEqual( "comparing saved with loaded", image.get(), img2.get()); // force pixel format conversion (don't destroy the old image) auto_ptr<Image> img3(OpenImage(filename, PF_R8G8B8)); CPPUNIT_ASSERT(SaveImage(filename, FF_PNG, img3.get()) == true); remove(filename); //== PALETTIZED SAVING TEST == // disabled until loading palettized PNGs with a correct palette format // is implemented. #if 0 char* plt_filename = tmpnam(0); CPPUNIT_ASSERT_MESSAGE("opening temporary file (palette)", plt_filename != 0); auto_ptr<Image> plt(CreateImage(256, 256, PF_I8, 256, PF_R8G8B8)); setRandomBytes((byte*)plt->getPixels(), 256 * 256); setRandomBytes((byte*)plt->getPalette(), 256); CPPUNIT_ASSERT(SaveImage(plt_filename, FF_PNG, plt.get()) == true); auto_ptr<Image> plt2(OpenImage(plt_filename, FF_PNG)); CPPUNIT_ASSERT_MESSAGE("reloading palettized image", plt2.get() != 0); CPPUNIT_ASSERT(plt2->getPaletteSize() == 256); CPPUNIT_ASSERT(plt2->getPaletteFormat() == PF_R8G8B8); CPPUNIT_ASSERT(plt2->getFormat() == PF_I8); AssertImagesEqual("Comparing palettized image", plt.get(), plt2.get()); remove(plt_filename); #endif }
int main (int argc, char *argv[]) { int choix = -1; int SimuChargee = 0; int SimuCalculee = 0; PtrSimulation simulation = NULL; gtk_init (&argc, &argv); while (choix != 0) { choix = menu (SimuChargee, SimuCalculee); switch (choix) { case 1 : simulation = LoadSimu (&SimuChargee); SimuCalculee = 0; break; case 2 : CalculerSimu (simulation); SimuCalculee = 1; break; case 3 : if(SimuCalculee == 1) SaveImage (simulation); break; case 4: if(SimuCalculee == 1) PrintReport (simulation); case 0 : break; default : break; } } return 0; }
GLuint GenSphereBumpmap() { GLuint id; glGenTextures(1, &id); glBindTexture(GL_TEXTURE_2D, id); uchar img[3 * 64 * 64], *p = img; for (int y = 0; y < 64; y++) { for (int x = 0; x < 64; x++) { int sx = x - 32; int sy = y - 32; Vector3 n; if (sx*sx + sy*sy < 32*32) { const int sz = (int)sqrt(static_cast<float>(32 * 32 - sx*sx - sy*sy)); n = Vector3(sx, sy, sz); n.ANormalize(); } // compress it into a color *(p++) = (uchar)(255 * (n.x * 0.5f + 0.5f)); *(p++) = (uchar)(255 * (n.y * 0.5f + 0.5f)); *(p++) = (uchar)(255 * (n.z * 0.5f + 0.5f)); } } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 3, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, img); SaveImage("sphere_bm.jpg", 3, GL_UNSIGNED_BYTE, 64, 64, img); return id; }
/****************************************************************************** * void SaveOnFileSave(HWND hwnd) * * frame window File/Save menu command handler * * parameters: * hwnd - window handle of active child window or NULL of none active ******************************************************************************/ void SaveOnFileSave(HWND hwnd) { CHILDINSTANCEDATA PICFAR* pInstance = ChildGetInstanceData(hwnd); BYTE PICHUGE* pSavedImage; DWORD dwSavedLen; SAVEOP *pSaveOp; char szFilename[_MAX_PATH + 1]; if ( hwnd == NULL || pInstance == NULL || !ChildIsModified(hwnd) ) return; /* File/Save should have been grayed */ pSaveOp = pInstance->pOpenOp->pSaveOp; lstrcpy(szFilename, pInstance->pszFilename); if ( pSaveOp == 0 || pSaveOp->nFoundParmVer == 0 || pInstance->bFormatModified ) { if ( !SaveGetSaveAs(szFilename, &pSaveOp) ) return; } /* save the image, then reopen the image into the same window so the user can see the result of the save options */ if ( SaveImage(hwnd, szFilename, pSaveOp, &pSavedImage, &dwSavedLen) ) /* re-open from saved image into same window */ OpenImage(hwnd, szFilename, pSavedImage, dwSavedLen, OP_SILENT | OP_INISETTINGS); }
void Pipeline::ResizeStage(ImageList images, Task* task) { // Resize images and split it by resolutions QHash<QString, ImageList> imagesByRes; for(QString res : task->outputRes) { imagesByRes[res] = resizer.Run(images, task->sourceRes, res, task->potSize); UpdateProgress(); } // Pass images to build atals stage if(task->atlas) BuildAtlasStage(imagesByRes, task); // Save resized images without building atlas else { for(const QString& resolution : imagesByRes.keys()) { for(auto entry : imagesByRes[resolution]) { QString filename = MakeFilename(entry.first, resolution, ExtensionForFormat(task->outputFormat)); if(!SaveImage(entry.second, task->outputDir, filename, task->outputFormat)) { errors.push_back(ERROR_MASK.arg(task->name).arg(ERROR_SAVE_MASK.arg(filename))); } } } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->openButton, SIGNAL(clicked()), this, SLOT(Open())); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(SaveImage())); connect(ui->SSDButton, SIGNAL(clicked()), this, SLOT(SSD())); connect(ui->SADButton, SIGNAL(clicked()), this, SLOT(SAD())); connect(ui->NCCButton, SIGNAL(clicked()), this, SLOT(NCC())); connect(ui->GTCheckBox, SIGNAL(clicked()), this, SLOT(GTOnOff())); connect(ui->gaussianButton, SIGNAL(clicked()), this, SLOT(Gaussian())); connect(ui->maxButton, SIGNAL(clicked()), this, SLOT(FindBestDisparity())); connect(ui->bilateralButton, SIGNAL(clicked()), this, SLOT(Bilateral())); connect(ui->segmentButton, SIGNAL(clicked()), this, SLOT(Segment())); connect(ui->renderButton, SIGNAL(clicked()), this, SLOT(Render())); connect(ui->renderSlider, SIGNAL(valueChanged(int)), this, SLOT(RenderSlider(int))); connect(ui->magicButton, SIGNAL(clicked()), this, SLOT(MagicStereo(int))); ui->GTCheckBox->setChecked(true); ui->pixelErrorLabel->setText(""); ui->gaussianSigmaSpinBox->setValue(1.0); ui->biSigmaSSpinBox->setValue(1.0); ui->biSigmaISpinBox->setValue(20.0); ui->renderSlider->setValue(100); ui->SADOffsetBox->setValue(2); ui->SSDOffsetBox->setValue(2); ui->NCCOffsetBox->setValue(2); ui->segmentGridBox->setValue(20); ui->segmentColorSpinBox->setValue(20.0); ui->segmentSpatialSpinBox->setValue(6.0); ui->segmentIterBox->setValue(4); m_Image1Display.setParent(ui->tab); m_Image2Display.setParent(ui->tab_2); m_GTDisplay.setParent(ui->tab_4); m_DisparityDisplay.setParent(ui->tab_3); m_ErrorDisplay.setParent(ui->tab_5); m_RenderDisplay.setParent(ui->tab_6); m_SegmentDisplay.setParent(ui->tab_7); m_Image1Display.window = this; m_Image2Display.window = this; m_GTDisplay.window = this; m_DisparityDisplay.window = this; m_ErrorDisplay.window = this; m_RenderDisplay.window = this; m_SegmentDisplay.window = this; ui->tabWidget->setCurrentIndex(0); m_LastRow = 0; m_SegmentIteration = 0; m_MatchCost = NULL; }
ImageEncoderFunc StreamEncoderFactory::GetEncoder(const std::string& encoder_spec, const PixelFormat& fmt) { const EncoderDetails encdet = EncoderDetailsFromString(encoder_spec); PANGO_ENSURE(encdet.file_type != ImageFileTypeUnknown); return [fmt,encdet](std::ostream& os, const Image<unsigned char>& img){ SaveImage(img,fmt,os,encdet.file_type,true,encdet.quality); }; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->openButton, SIGNAL(clicked()), this, SLOT(OpenImage())); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(SaveImage())); connect(ui->saveDisplayButton, SIGNAL(clicked()), this, SLOT(SaveDisplayImage())); connect(ui->resetButton, SIGNAL(clicked()), this, SLOT(ResetImage())); connect(ui->toggleButton, SIGNAL(pressed()), this, SLOT(ToggleImage())); connect(ui->toggleButton, SIGNAL(released()), this, SLOT(ToggleImage())); connect(ui->bwButton, SIGNAL(clicked()), this, SLOT(BlackWhiteImage())); connect(ui->noiseButton, SIGNAL(clicked()), this, SLOT(AddNoise())); connect(ui->meanButton, SIGNAL(clicked()), this, SLOT(MeanBlurImage())); connect(ui->medianButton, SIGNAL(clicked()), this, SLOT(MedianImage())); connect(ui->gaussianBlurButton, SIGNAL(clicked()), this, SLOT(GaussianBlurImage())); connect(ui->firstDerivButton, SIGNAL(clicked()), this, SLOT(FirstDerivImage())); connect(ui->secondDerivButton, SIGNAL(clicked()), this, SLOT(SecondDerivImage())); connect(ui->sharpenButton, SIGNAL(clicked()), this, SLOT(SharpenImage())); connect(ui->sobelButton, SIGNAL(clicked()), this, SLOT(SobelImage())); connect(ui->bilateralButton, SIGNAL(clicked()), this, SLOT(BilateralImage())); connect(ui->halfButton, SIGNAL(clicked()), this, SLOT(HalfImage())); connect(ui->rotateButton, SIGNAL(clicked()), this, SLOT(RotateImage())); connect(ui->peaksButton, SIGNAL(clicked()), this, SLOT(FindPeaksImage())); connect(ui->houghButton, SIGNAL(clicked()), this, SLOT(HoughImage())); connect(ui->crazyButton, SIGNAL(clicked()), this, SLOT(CrazyImage())); connect(ui->randomButton, SIGNAL(clicked()), this, SLOT(RandomSeedImage())); connect(ui->pixelButton, SIGNAL(clicked()), this, SLOT(PixelSeedImage())); connect(ui->histogramButton, SIGNAL(clicked()), this, SLOT(HistogramSeedImage())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(OpenImage())); connect(ui->zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(Zoom(int))); connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(Brightness(int))); connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(Scroll(int))); connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(Scroll(int))); ui->meanBox->setValue(2); ui->medianBox->setValue(2); ui->blurSpinBox->setValue(2.0); ui->firstDerivSpinBox->setValue(2.0); ui->secondDerivSpinBox->setValue(2.0); ui->sharpenSigmaSpinBox->setValue(2.0); ui->sharpenMagSpinBox->setValue(1.0); ui->bilateralSigmaSSpinBox->setValue(2.0); ui->bilateralSigmaISpinBox->setValue(20.0); ui->noiseSpinBox->setValue(10.0); ui->orientationSpinBox->setValue(10.0); ui->peakThresholdSpinBox->setValue(10.0); ui->colorNoiseCheckBox->setChecked(true); ui->zoomSlider->setValue(0); ui->brightnessSlider->setValue(0); ui->clusterBox->setValue(4); displayImage = QImage(ui->ImgDisplay->width(), ui->ImgDisplay->height(), QImage::Format_RGB32); }
int main(int argc, char **argv) { // Check command usage if(argc != 5) { fprintf(stderr,"\nUsage: \n%s SampleImageFile InputImageFile OutputImageFile ThresholdValue\n\n",argv[0]) ; return(1) ; } //Dimension images to be used, test for successful memory allocation Image *sample_image, *input_image, *thresholded_image ; sample_image = malloc(sizeof(Image)) ; input_image = malloc(sizeof(Image)) ; thresholded_image = malloc(sizeof(Image)) ; if(sample_image == NULL || input_image == NULL || thresholded_image == NULL) { fprintf(stderr,"Error: Unsuccessful memory allocation\n") ; return(1) ; } // Find Sample Image's Avg, and StDev int ThresholdValue ; Color clr ; float RedAvg,GreenAvg,BlueAvg,RedStd,GreenStd,BlueStd ; ReadImage(argv[1],sample_image) ; ImageAvgStdDev(sample_image,&RedAvg,&GreenAvg,&BlueAvg, &RedStd,&GreenStd,&BlueStd) ; // Read image to Threshold and set Output Image Size int row, col ; ReadImage(argv[2],input_image) ; GetSize(input_image,&row,&col) ; SetSize(thresholded_image,row,col) ; // Threshold Image and Write to Output image file ThresholdValue = atoi(argv[4]) ; ThresholdImage(input_image,RedAvg,GreenAvg,BlueAvg,RedStd, GreenStd,BlueStd,ThresholdValue,thresholded_image) ; // Remove backgrounds using UnionFind RemoveBackground(thresholded_image) ; // Save the image SaveImage(argv[3],thresholded_image) ; }
// Called from ThreadDisplay bool ImageSaveDlg::SaveIfNecessary( PvBuffer *aRawBuffer ) { if ( !mSaveEnabled ) { return false; } bool lSaveThisOne = false; double lBitsPerImage; double lBitsPerMs; switch( mSaveThrottling ) { case ONEOUTOF: // 1 image every mOneOf captured images mCapturedSince++; if ( mCapturedSince >= mOneOutOf ) { lSaveThisOne = true; mCapturedSince = 0; } break; case MAXRATE: // maximum of one out of every mMaxRate ms if ( mPrevious.elapsed() >= static_cast<int>( mMaxRate ) ) { lSaveThisOne = true; mPrevious.start(); } break; case AVERAGETHROUGHPUT: // maintain mAverageThroughput Mbits/s average lBitsPerImage = aRawBuffer->GetAcquiredSize() * 8; lBitsPerMs = mAverageThroughput * 1048.576; if ( mPrevious.elapsed() >= lBitsPerImage / lBitsPerMs ) { lSaveThisOne = true; mPrevious.start(); } break; case NOTHROTTLE: lSaveThisOne = true; break; default: assert(FALSE); break; } if ( lSaveThisOne ) { return SaveImage( aRawBuffer ); } return false; }
ControllerImageFusion::ControllerImageFusion(Ui::MainWindow *ui, QMainWindow* MainWindow) : QObject(MainWindow) { _MainView = ui->mainTreeView; _TargetSoursesList = ui->IF_sourses_list; _TargetResultsList = ui->IF_results_list; _PanList = ui->IF_pan_list; _AddToSourcesList = ui->IF_add_selected_to_list; _RemoveFromSourcesList = ui->IF_remove_from_source_list; _SetPan = ui->IF_set_pan; _StartButton = ui->IF_start; _Preview = ui->IF_preview; _Save = ui->IF_save; _AddColoredImage = ui->IF_add_color_image; _MainWindow = MainWindow; _UseNormalization = ui->IF_use_normalization; _WindowSize = ui->IF_windowSize; _OrthogonalizationType = ui->IF_orthogonalization_type; _TargetResultsList->setDragEnabled(true); _TargetResultsList->viewport()->setAcceptDrops(true); _TargetResultsList->setDropIndicatorShown(true); _TargetResultsList->setDefaultDropAction(Qt::MoveAction); QList<QMap<int, QVariant> > modelHeaders; QMap<int, QVariant> Name; Name.insert(0, QString("File")); modelHeaders.append(Name); _TargetSoursesModel = new GrayScaleImageModel(modelHeaders); _TargetSoursesList->setModel(_TargetSoursesModel); _TargetResultsModel = new StandardImageModel(modelHeaders); _TargetResultsList->setModel(_TargetResultsModel); _PanModel = new StandardImageModel(modelHeaders); _PanList->setModel(_PanModel); // connect signals and slots QObject::connect(_AddToSourcesList, SIGNAL(clicked()), this, SLOT(AddSelectedToSoursesList())); QObject::connect(_RemoveFromSourcesList, SIGNAL(clicked()), this, SLOT(RemoveFromSoursesList())); QObject::connect(_StartButton, SIGNAL(clicked()), this, SLOT(StartFuision())); QObject::connect(_SetPan, SIGNAL(clicked()), this, SLOT(SetPanImage())); QObject::connect(_Preview, SIGNAL(clicked()), this, SLOT(ResultPreview())); QObject::connect(_Save, SIGNAL(clicked()), this, SLOT(SaveImage())); QObject::connect(_AddColoredImage, SIGNAL(clicked()), this, SLOT(AddColoredImageToResults())); }
bool cRenderQueue::RenderStill(const QString& filename) { QString extension; enumImageFileType imageFormat = (enumImageFileType) gPar->Get<int>("queue_image_format"); extension = ImageFileExtension(imageFormat); QString saveFilename = QFileInfo(filename).baseName() + extension; //setup of rendering engine cRenderJob *renderJob = new cRenderJob(queuePar, queueParFractal, image, &gQueue->stopRequest, imageWidget); connect(renderJob, SIGNAL(updateProgressAndStatus(const QString&, const QString&, double)), this, SIGNAL(updateProgressAndStatus(const QString&, const QString&, double))); connect(renderJob, SIGNAL(updateStatistics(cStatistics)), this, SIGNAL(updateStatistics(cStatistics))); cRenderingConfiguration config; if (systemData.noGui) { config.DisableProgressiveRender(); config.DisableRefresh(); } config.EnableNetRender(); renderJob->Init(cRenderJob::still, config); gQueue->stopRequest = false; //render image bool result = renderJob->Execute(); if (!result) { delete renderJob; return false; } QString fullSaveFilename = gPar->Get<QString>("default_image_path") + QDir::separator() + saveFilename; SaveImage(fullSaveFilename, imageFormat, image); fullSaveFilename = gPar->Get<QString>("default_image_path") + QDir::separator() + QFileInfo(filename).baseName() + ".fract"; cSettings parSettings(cSettings::formatCondensedText); parSettings.CreateText(queuePar, queueParFractal); parSettings.SaveToFile(fullSaveFilename); delete renderJob; return true; }
bool CDocCommands::FileTab(CString& strCommand) { if (strCommand == "OPEN") return OpenImage(); if (strCommand == "CLOSE") return CloseImage(); if (strCommand == "SAVE") return SaveImage(); return false; }
void CPicapDoc::OnFileSave() { // TODO: Add your command handler code here CFileDialog dlg(FALSE, DEFAULT_SAVE_EXT_STR, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, FILE_FILTER_STR); if(IDOK == dlg.DoModal()) { if (!SaveImage(dlg.GetFileName())) { AfxMessageBox(SAVE_IMAGE_FAILED_STR); } } }
void Pipeline::BuildAtlasStage(QHash<QString,ImageList> images, Task* task) { for(const QString& resolution : images.keys()) { int width = task->atlasParams.sizes[resolution].width(); int height = task->atlasParams.sizes[resolution].height(); if(!MathUtils::IsPowerOfTwo(width) || !MathUtils::IsPowerOfTwo(height)) { QString error = ERROR_MASK.arg(task->name).arg("Sizes of atlas for resolution \"%1\" must be power of two"); errors.push_back(error.arg(resolution)); return; } QPair<QImage,QJsonObject> atlas = atlasBuilder.Run(images[resolution], width, height, task->outputFormat, task->atlasParams); // Save atlas image QString imageFilename = MakeFilename(task->atlasParams.name, resolution, ExtensionForFormat(task->outputFormat)); if(!SaveImage(atlas.first, task->outputDir, imageFilename, task->outputFormat)) { errors.push_back(ERROR_MASK.arg(task->name).arg(ERROR_SAVE_MASK.arg(imageFilename))); return; } // Save atlas json description QDir outputDir(task->outputDir); QString filename = MakeFilename(task->atlasParams.name, resolution, "atlas"); QFile file(outputDir.absoluteFilePath(filename)); if(!file.open(QIODevice::WriteOnly)) { errors.push_back(ERROR_MASK.arg(task->name).arg(ERROR_SAVE_MASK.arg(filename))); return; } QJsonDocument doc(atlas.second); file.write(doc.toJson()); auto atlasErrors = atlasBuilder.GetErrors(); if(!atlasErrors.empty()) { for(auto& error : atlasErrors) { QString resError = QString("%1 for \"%2\" resolution").arg(error).arg(resolution); errors.push_back(ERROR_MASK.arg(task->name).arg(resError)); } } UpdateProgress(); } }
void SaveViewFromFbo(std::string prefix, View& view, float scale) { PANGOLIN_UNUSED(prefix); #ifndef HAVE_GLES const Viewport orig = view.v; view.v.l = 0; view.v.b = 0; view.v.w = (int)(view.v.w * scale); view.v.h = (int)(view.v.h * scale); const int w = view.v.w; const int h = view.v.h; float origLineWidth; glGetFloatv(GL_LINE_WIDTH, &origLineWidth); glLineWidth(origLineWidth * scale); float origPointSize; glGetFloatv(GL_POINT_SIZE, &origPointSize); glPointSize(origPointSize * scale); // Create FBO GlTexture color(w,h); GlRenderBuffer depth(w,h); GlFramebuffer fbo(color, depth); // Render into FBO fbo.Bind(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); view.Render(); glFlush(); #ifdef HAVE_PNG const PixelFormat fmt = PixelFormatFromString("RGBA32"); TypedImage buffer(w, h, fmt ); glReadBuffer(GL_BACK); glPixelStorei(GL_PACK_ALIGNMENT, 1); // TODO: Avoid this? glReadPixels(0,0,w,h, GL_RGBA, GL_UNSIGNED_BYTE, buffer.ptr ); SaveImage(buffer, fmt, prefix + ".png", false); #endif // HAVE_PNG // unbind FBO fbo.Unbind(); // restore viewport / line width view.v = orig; glLineWidth(origLineWidth); glPointSize(origPointSize); #endif // HAVE_GLES }
int main(int argc, char **argv) { int i, j, k, sx, sy; if (argc < 5) return 0; for (k = 1; k < 5; ++k) { freopen(argv[k], "rb", stdin); LoadImage(H*W/4, s); sx = (k-1)/2*256; sy = (k-1)%2*256; for (i = 0; i < H/2; ++i) for (j = 0; j < W/2; ++j) t[sx+i][sy+j] = s[i][j]; } SaveImage(H*W, t); }
void OpenCVPlotter::Refresh(WaitTime waitTime) { if (IsEnabled()) { cvShowImage(m_Data->windowName.c_str(), IMG); cvWaitKey(waitTime); if ((m_hd.cfg.ValueOf("plotter.createVideo", true) == true)) WriteCurrentFrame(); if ((m_hd.cfg.ValueOf("plotter.saveImages", true) == true)) SaveImage("", m_hd.cfg.ValueOf("plotter.pixDirectory")); } }
//================================================================================= int main (int argc, char**argv) { // get the filename from the command line, or use out.bmp if none supplied const char* fileName = argc < 2 ? "out.bmp" : argv[1]; // report the params const size_t numThreads = FORCE_SINGLE_THREAD() ? 1 : std::thread::hardware_concurrency(); printf("Rendering a %ix%i image with %i samples per pixel and %i ray bounces.\n", c_imageWidth, c_imageHeight, c_samplesPerPixel, c_numBounces); printf("Using %i threads.\n", numThreads); // allocate memory for our rendered image g_pixels.resize(c_numPixels); // time this block with an STimer { STimer timer; // if going multithreaded, spin up some threads to do rendering work, and wait for them to be done if (numThreads > 1) { auto start = std::chrono::high_resolution_clock::now(); std::vector<std::thread> threads; threads.resize(numThreads); for (std::thread& t : threads) t = std::thread(ThreadFunc, std::ref(timer)); for (std::thread& t : threads) t.join(); } // else if single threaded, just call the rendering function from the main thread else { ThreadFunc(timer); } } // save the image if (!SaveImage(fileName)) printf("Could not save image as %s.\n", fileName); else printf("Saved image as %s.\n", fileName); // all done system("pause"); return 0; }
int main(int arvc,int* argv[]) { struct MyImage* p_img =CreatImage(800,800); if(p_img != NULL) { printf("not null\n"); } FillImage(p_img,0xaa);//最大为全白 最小为全黑 DrawImage(p_img,300); SaveImage(p_img,"../bagua.pgm"); DestoryImage(p_img); return 1; }
void SaveFramebuffer(std::string prefix, const Viewport& v) { PANGOLIN_UNUSED(prefix); PANGOLIN_UNUSED(v); #ifndef HAVE_GLES #ifdef HAVE_PNG PixelFormat fmt = PixelFormatFromString("RGBA32"); TypedImage buffer(v.w, v.h, fmt ); glReadBuffer(GL_BACK); glPixelStorei(GL_PACK_ALIGNMENT, 1); // TODO: Avoid this? glReadPixels(v.l, v.b, v.w, v.h, GL_RGBA, GL_UNSIGNED_BYTE, buffer.ptr ); SaveImage(buffer, fmt, prefix + ".png", false); #endif // HAVE_PNG #endif // HAVE_GLES }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), last_canvas_selected_(NULL) { ui->setupUi(this); LoadSettings(); edit_mode_buttons_[EDIT_MODE_IMAGE] = ui->actionEditModeImage; edit_mode_buttons_[EDIT_MODE_GRID] = ui->actionEditModeGrid; edit_mode_buttons_[EDIT_MODE_VOXEL] = ui->actionEditModeVoxel; if(edit_mode_buttons_.contains(Options::instance()->current_edit_mode_)){ current_edit_mode_button_ = edit_mode_buttons_[Options::instance()->current_edit_mode_]; current_edit_mode_button_->setChecked(true); } tool_buttons_[TOOL_SELECTION] = ui->actionSelection_Tool; tool_buttons_[TOOL_ZOOM] = ui->actionZoom_Tool; tool_buttons_[TOOL_PENCIL] = ui->actionPencil_Tool; tool_buttons_[TOOL_FILL] = ui->actionFill_Tool; tool_buttons_[TOOL_LINE] = ui->actionLine_Tool; tool_buttons_[TOOL_RECTANGLE] = ui->actionRectangle_Tool; tool_buttons_[TOOL_ELIPSE] = ui->actionElipse_Tool; if(tool_buttons_.contains(Options::instance()->current_tool_)){ current_tool_button_ = tool_buttons_[Options::instance()->current_tool_]; current_tool_button_->setChecked(true); } // Menu Actions connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(OpenImage())); connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(SaveImage())); connect(ui->actionTile_Size,SIGNAL(triggered()),this,SLOT(SetCursorSize())); connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(NewImage())); // Tool Actions connect(ui->actionSelection_Tool,SIGNAL(triggered()),this,SLOT(SelectSelectionTool())); connect(ui->actionFill_Tool,SIGNAL(triggered()),this,SLOT(SelectFillTool())); connect(ui->actionPencil_Tool,SIGNAL(triggered()),this,SLOT(SelectSelectionTool())); connect(ui->mdiArea,SIGNAL(subWindowActivated(QMdiSubWindow*)),this,SLOT(CurrentWindowChanged(QMdiSubWindow*))); }
int main() { CTFDSConfigValue::GetInstance()->LoadConfig("config.ini"); CTFDSBrowseDir tfdsBD; CreateThread(NULL, 0, BrowserDir, (LPVOID)&tfdsBD, 0, NULL); CAutoWarningController a; a.Init(); //初始化数据库连接 ADOConn *ado = new ADOConn(); cout<<"初始化完毕"<<endl; while (1) { if (g_queue.CanGetTopNFilePath()) { vector<const string> imgPaths = g_queue.GetTopNFilePath(); cout<<"-----待处理图片----"<<endl; for (int i = 0; i != imgPaths.size(); ++i) { cout<<imgPaths[i]<<endl; } cout<<"-------------------"<<endl; a.Process(imgPaths); vector<SProcessResult> result = a.GetProcessResultArray(); /**********处理完图片后将结果传到数据库******/ if (ado->InsertRecord(result)) { SaveImage(result); PrintErrorInfo(result); } /**********处理完图片后将结果传到数据库******/ } } ado->ExitConnect(); delete ado; delete CTFDSConfigValue::GetInstance(); return 0; }
// Test image saving void ImgFilesService::TestImgSaving() { QWidget wdt; QString imgPath = QFileDialog::getOpenFileName(&wdt, "Open test image...", QDir::currentPath(), "IMG files (*.png *.jpg *.jpeg *.bmp *.tiff)"); QString pathToSave = QFileDialog::getSaveFileName(&wdt, "Save as...", QDir::currentPath(), "IMG files (*.png *.jpg *.jpeg *.bmp *.tiff)"); qDebug() << "From:" << imgPath; qDebug() << "To:" << pathToSave; QImage img(imgPath); SaveImage(img, pathToSave); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->openButton, SIGNAL(clicked()), this, SLOT(OpenImage())); connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(SaveImage())); connect(ui->harrisButton, SIGNAL(clicked()), this, SLOT(HarrisCornerImage())); connect(ui->matchButton, SIGNAL(clicked()), this, SLOT(MatchImages())); connect(ui->RANSACButton, SIGNAL(clicked()), this, SLOT(RANSAC())); connect(ui->stitchButton, SIGNAL(clicked()), this, SLOT(StitchImages())); ui->harrisSpinBox->setValue(2.0); ui->harrisThresSpinBox->setValue(50.0); ui->RANSACThresSpinBox->setValue(5.0); ui->iterationsBox->setValue(200); ui->tabWidget->setCurrentIndex(0); }
// called from GEVPlayerDlg bool ImageSaveDlg::SaveThisImage() { assert( mDisplayThread != NULL ); if ( mDisplayThread == NULL ) { return false; } bool lResult = false; PvBuffer* lBuffer = mDisplayThread->RetrieveLatestBuffer(); if ( lBuffer != NULL ) { lResult = SaveImage( lBuffer ); } mDisplayThread->ReleaseLatestBuffer(); return lResult; }
/// AddImg::Measure double AddImg::Measure(class ImageLayout *src,class ImageLayout *sr2,double in) { ULONG width = (src->WidthOf() > sr2->WidthOf()) ?(src->WidthOf()) :(sr2->WidthOf()); ULONG height = (src->HeightOf() > sr2->HeightOf())?(src->HeightOf()):(sr2->HeightOf()); UWORD d1 = src->DepthOf(); UWORD d2 = sr2->DepthOf(); UWORD depth = src->DepthOf() + sr2->DepthOf(); UWORD i; CreateComponents(width,height,depth); for(i = 0;i < d1;i++) { m_pComponent[i].m_ucBits = src->BitsOf(i); m_pComponent[i].m_bSigned = src->isSigned(i); m_pComponent[i].m_bFloat = src->isFloat(i); m_pComponent[i].m_ucSubX = m_ulWidth / src->WidthOf(i); m_pComponent[i].m_ucSubY = m_ulHeight / src->HeightOf(i); m_pComponent[i].m_ulWidth = src->WidthOf(i); m_pComponent[i].m_ulHeight= src->HeightOf(i); m_pComponent[i].m_ulBytesPerPixel = src->BytesPerPixel(i); m_pComponent[i].m_ulBytesPerRow = src->BytesPerRow(i); m_pComponent[i].m_pPtr = const_cast<APTR>(src->DataOf(i)); } for(i = 0;i < d2;i++) { m_pComponent[i+d1].m_ucBits = sr2->BitsOf(i); m_pComponent[i+d1].m_bSigned = sr2->isSigned(i); m_pComponent[i+d1].m_bFloat = sr2->isFloat(i); m_pComponent[i+d1].m_ucSubX = m_ulWidth / sr2->WidthOf(i); m_pComponent[i+d1].m_ucSubY = m_ulHeight / sr2->HeightOf(i); m_pComponent[i+d1].m_ulWidth = sr2->WidthOf(i); m_pComponent[i+d1].m_ulHeight= sr2->HeightOf(i); m_pComponent[i+d1].m_ulBytesPerPixel = sr2->BytesPerPixel(i); m_pComponent[i+d1].m_ulBytesPerRow = sr2->BytesPerRow(i); m_pComponent[i+d1].m_pPtr = const_cast<APTR>(sr2->DataOf(i)); } SaveImage(m_pcTargetFile,m_TargetSpecs); return in; }
/****************************************************************************** * void SaveOnFileSaveAs(HWND hwnd) * * frame window File/Save As menu command handler * * parameters: * hwnd - window handle of active child window or NULL of none active * * notes: * uses common file save dialog * * Determines the save opcode according to what filter the user chooses * in the save dialog. The file extension is whatever the user enters * so it's possible for the user to specify a senseless extension. * * constructs file filter list on the fly from save opcodes whose * opcode dll is present. ******************************************************************************/ void SaveOnFileSaveAs(HWND hwnd) { CHILDINSTANCEDATA PICFAR* pInstance = ChildGetInstanceData(hwnd); char szFilename[_MAX_PATH + 1]; SAVEOP *pSaveOp; BYTE PICHUGE* pSavedImage; DWORD dwSavedLen; if ( hwnd == NULL || pInstance == NULL ) return; /* File/Save As should have been grayed */ lstrcpy(szFilename, pInstance->pszFilename); pSaveOp = pInstance->pOpenOp->pSaveOp; if ( !SaveGetSaveAs(szFilename, &pSaveOp) ) return; /* save the image, then open the image into a new window so the user can see the result of the save options */ if ( SaveImage(hwnd, szFilename, pSaveOp, &pSavedImage, &dwSavedLen) ) /* re-open from saved image into new window */ OpenImageWindow(szFilename, pSavedImage, dwSavedLen, OP_SILENT | OP_INISETTINGS); }
int main() { // Part 2-h: use the SaveImage function. Color fuchsia = Color(193, 84, 193); Image test = Image(100,100); test.Fill(fuchsia); test.SetColor(0, 0, Color(255, 255, 255)); Color black = Color(0, 0, 0); // testing line Line line = Line(Coord(0, 0), Coord(50, 100), black); //line.Draw(test); Line li = Line(Coord(20, 33), Coord(60, 90), black); //li.Draw(test); Line lid = Line(Coord(80, 60), Coord(0, 50), black); //lid.Draw(test); Line lie = Line(Coord(60, 88), Coord(100, 5), black); lie.Draw(test); SaveImage(test, "imageyo.bmp"); std::cin.get(); }