std::auto_ptr<QDomDocument> GImageMappingsExporter::ExportImageMappings(QSharedPointer<GImageMappings> oImageMappings) { std::auto_ptr<QDomDocument> oDoc(new QDomDocument); QDomElement oElementImageMappings(oDoc->createElement(GImageMappings::CXMLTag)); // Iterate through the Images and export them QList<GImageMap *> oImageList(oImageMappings->GetAllImageMaps()); QList<GImageMap *>::iterator oImageIterator(oImageList.begin()); GImageMap* oImage; while (oImageIterator != oImageList.end()) { oImage = *oImageIterator; oDoc = ExportImage(oImage, oDoc, &oElementImageMappings); ++oImageIterator; } // Append generated elements into Document oDoc->appendChild(oElementImageMappings); return oDoc; }
void KeyboardKeys(unsigned char key, int x, int y) { if(key == 'c') { memset(cov_img, 0.0, width*height); generateCovariance = !generateCovariance; } else if(key == 'B') { generateReference = !generateReference; } else if(key == 'b') { generateBackground = !generateBackground; } else if(key == 'h') { displayBackground = !displayBackground; } else if(key == 'f') { useCovFilter = !useCovFilter; } else if(key == '+') { Material phong(Vector(), Vector(), Vector(1,1,1)*.999, spheres[1].mat.exponent * 10); spheres[1].mat = phong; nPasses = 0; } else if(key == '-') { Material phong(Vector(), Vector(), Vector(1,1,1)*.999, fmax(spheres[1].mat.exponent / 10, 1.0)); spheres[1].mat = phong; nPasses = 0; } else if(key == 'p') { ExportImage(width*mouse.X, height*mouse.Y); } else if(key == 'd') { std::cout << sout.str() << std::endl; } glutPostRedisplay(); }
/// Saves the current image in the OpenCL memory buffer to the specified FITS file /// If the OpenCL memory has not been initialzed, this function immediately returns void CLibOI::ExportImage(string filename) { if(mImage_cl == NULL) return; // TODO: Adapt for multi-spectral images Normalize(); // Create a storage buffer for the image and copoy the image to it: valarray<float> image(mImageWidth * mImageHeight * mImageDepth); ExportImage(&image[0], mImageWidth, mImageHeight, mImageDepth); // write out the FITS file: fitsfile *fptr; int status = 0; long fpixel = 1, naxis = 2, nelements; long naxes[2]; /*Initialise storage*/ naxes[0] = (long) mImageWidth; naxes[1] = (long) mImageHeight; nelements = mImageWidth * mImageWidth; /*Create new file*/ if (status == 0) fits_create_file(&fptr, filename.c_str(), &status); /*Create primary array image*/ if (status == 0) fits_create_img(fptr, FLOAT_IMG, naxis, naxes, &status); double RPMAS = (M_PI / 180.0) / 3600000.0; double image_scale_rad = mImageScale * RPMAS; // Write keywords to get WCS to work // fits_write_key_dbl(fptr, "CDELT1", -image_scale_rad, 3, "Radians per pixel", &status); fits_write_key_dbl(fptr, "CDELT2", image_scale_rad, 3, "Radians per pixel", &status); fits_write_key_dbl(fptr, "CRVAL1", 0.0, 3, "X-coordinate of reference pixel", &status); fits_write_key_dbl(fptr, "CRVAL2", 0.0, 3, "Y-coordinate of reference pixel", &status); fits_write_key_lng(fptr, "CRPIX1", naxes[0]/2, "reference pixel in X", &status); fits_write_key_lng(fptr, "CRPIX2", naxes[1]/2, "reference pixel in Y", &status); fits_write_key_str(fptr, "CTYPE1", "RA", "Name of X-coordinate", &status); fits_write_key_str(fptr, "CTYPE2", "DEC", "Name of Y-coordinate", &status); fits_write_key_str(fptr, "CUNIT1", "rad", "Unit of X-coordinate", &status); fits_write_key_str(fptr, "CUNIT2", "rad", "Unit of Y-coordinate", &status); /*Write a keywords (datafile, target, image scale) */ // if (status == 0) // fits_update_key(fptr, TSTRING, "DATAFILE", "FakeImage", "Data File Name", &status); // if (status == 0) // fits_update_key(fptr, TSTRING, "TARGET", "FakeImage", "Target Name", &status); // if (status == 0) // fits_update_key(fptr, TFLOAT, "SCALE", &mImageScale, "Scale (mas/pixel)", &status); /*Write image*/ if (status == 0) fits_write_img(fptr, TFLOAT, fpixel, nelements, &image[0], &status); /*Close file*/ if (status == 0) fits_close_file(fptr, &status); /*Report any errors*/ fits_report_error(stderr, status); }
void TemplateFrame::OnSaveCanvasImageAs(wxCommandEvent& event) { ExportImage(template_canvas, activeFrName); }
void LevelEdit::ExportingReady() //slot { if(!sceneCreated) return; if(!scene) return; long x, y, h, w, th, tw; bool proportion; bool forceTiled=false; QString inifile = AppPathManager::settingsFile(); QSettings settings(inifile, QSettings::IniFormat); settings.beginGroup("Main"); latest_export_path = settings.value("export-path", AppPathManager::userAppDir()).toString(); proportion = settings.value("export-proportions", true).toBool(); settings.endGroup(); if(scene->isFullSection) { x=LvlData.sections[LvlData.CurSection].size_left; y=LvlData.sections[LvlData.CurSection].size_top; w=LvlData.sections[LvlData.CurSection].size_right; h=LvlData.sections[LvlData.CurSection].size_bottom; w=(long)fabs(x-w); h=(long)fabs(y-h); } else { x=qRound(scene->captutedSize.x()); y=qRound(scene->captutedSize.y()); w=qRound(scene->captutedSize.width()); h=qRound(scene->captutedSize.height()); } tw=w; th=h; QVector<long> imgSize; imgSize.push_back(th); imgSize.push_back(tw); imgSize.push_back((int)proportion); ExportToImage ExportImage(imgSize); ExportImage.setWindowFlags (Qt::Window | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); ExportImage.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, ExportImage.size(), qApp->desktop()->availableGeometry())); if(ExportImage.exec()!=QDialog::Rejected) imgSize = ExportImage.imageSize; else return; if(imgSize.size()>=3) if((imgSize[0]<0)||(imgSize[1]<0)) return; QString fileName = QFileDialog::getSaveFileName(this, tr("Export current section to image"), latest_export_path + "/" + QString("%1_Section_%2%3.png").arg( QFileInfo(curFile).baseName() ) .arg(LvlData.CurSection+1) .arg(scene->isFullSection?"":("_"+QString::number(qrand()))), tr("PNG Image (*.png)")); if (fileName.isEmpty()) return; forceTiled = ExportImage.TiledBackground(); QFileInfo exported(fileName); QProgressDialog progress(tr("Saving section image..."), tr("Abort"), 0, 100, this); progress.setWindowTitle(tr("Please wait...")); progress.setWindowModality(Qt::WindowModal); progress.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); progress.setFixedSize(progress.size()); progress.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, progress.size(), qApp->desktop()->availableGeometry())); progress.setCancelButton(0); progress.setMinimumDuration(0); //progress.show(); if(!progress.wasCanceled()) progress.setValue(0); qApp->processEvents(); scene->stopAnimation(); //Reset animation to 0 frame if(ExportImage.HideWatersAndDoors()) scene->hideWarpsAndDoors(false); if(forceTiled) scene->setTiledBackground(true); if(!progress.wasCanceled()) progress.setValue(10); qApp->processEvents(); scene->clearSelection(); // Clear selection on export latest_export_path = exported.absoluteDir().path(); proportion = imgSize[2]; th=imgSize[0]; tw=imgSize[1]; qApp->processEvents(); QImage img(tw,th,QImage::Format_ARGB32_Premultiplied); if(!progress.wasCanceled()) progress.setValue(20); qApp->processEvents(); QPainter p(&img); if(!progress.wasCanceled()) progress.setValue(30); qApp->processEvents(); scene->render(&p, QRectF(0,0,tw,th),QRectF(x,y,w,h)); qApp->processEvents(); p.end(); if(!progress.wasCanceled()) progress.setValue(40); qApp->processEvents(); img.save(fileName); qApp->processEvents(); if(!progress.wasCanceled()) progress.setValue(90); qApp->processEvents(); if(scene->opts.animationEnabled) scene->startAnimation(); // Restart animation if(ExportImage.HideWatersAndDoors()) scene->hideWarpsAndDoors(true); if(forceTiled) scene->setTiledBackground(false); if(!progress.wasCanceled()) progress.setValue(100); if(!progress.wasCanceled()) progress.close(); settings.beginGroup("Main"); settings.setValue("export-path", latest_export_path); settings.setValue("export-proportions", proportion); settings.endGroup(); }