void Preview::showFrame(){ QImage myImage((uchar *)input,buffer->width, buffer->height, QImage::Format_RGB32); ui->imgLabel->setPixmap(QPixmap::fromImage(myImage.scaled(ui->imgLabel->width(),ui->imgLabel->height()))); }
int main() { std::cout<<"------------Image Created---------\n"; ImageWrite myImage(400,400); myImage.clear(30,24,200); myImage.save("Test.ppm"); for(int a = 5; a < 395; a+=5) //A FOR LOOP THAT CREATES A LINED IMAGE TO SCREEN TO CHECK IF FUNCTION WORKS FOR ALL OCTANTS { myImage.plotLine({200,200},{5,a}); } for(int b = 5; b < 395; b+=5) { myImage.plotLine({200,200},{b,5}); } for(int c = 5; c < 395; c+=5) { myImage.plotLine({200,200},{395,c}); } for(int d = 5; d < 395; d+=5) { myImage.plotLine({200,200},{d,395}); } //myImage.plotLine(200,200,400,400); //myImage.plotLine({200,0},{200,200}); myImage.save("BresenhamLinePrinciple.ppm"); return EXIT_SUCCESS; }
/* before saving the result to the file "myResult.ppm". */ int BatchModeMain(int argc, char** argv) { if (!myScene) { std::cout << "BatchModeMain() called, but the scene hasn't been initialized!!\n"; exit(0); } Image myImage( myScene->GetWidth(), myScene->GetHeight()); ShootRays( myImage, myScene ); myImage.Save( "myResult.ppm" ); return 0; }
bool QgsRenderChecker::runTest( QString theTestName, unsigned int theMismatchCount ) { if ( mExpectedImageFile.isEmpty() ) { qDebug( "QgsRenderChecker::runTest failed - Expected Image File not set." ); mReport = "<table>" "<tr><td>Test Result:</td><td>Expected Result:</td></tr>\n" "<tr><td>Nothing rendered</td>\n<td>Failed because Expected " "Image File not set.</td></tr></table>\n"; return false; } // // Load the expected result pixmap // QImage myExpectedImage( mExpectedImageFile ); mMatchTarget = myExpectedImage.width() * myExpectedImage.height(); // // Now render our layers onto a pixmap // QImage myImage( myExpectedImage.width(), myExpectedImage.height(), QImage::Format_RGB32 ); myImage.setDotsPerMeterX( myExpectedImage.dotsPerMeterX() ); myImage.setDotsPerMeterY( myExpectedImage.dotsPerMeterY() ); myImage.fill( qRgb( 152, 219, 249 ) ); QPainter myPainter( &myImage ); myPainter.setRenderHint( QPainter::Antialiasing ); mpMapRenderer->setOutputSize( QSize( myExpectedImage.width(), myExpectedImage.height() ), myExpectedImage.logicalDpiX() ); QTime myTime; myTime.start(); mpMapRenderer->render( &myPainter ); mElapsedTime = myTime.elapsed(); myPainter.end(); // // Save the pixmap to disk so the user can make a // visual assessment if needed // mRenderedImageFile = QDir::tempPath() + QDir::separator() + theTestName + "_result.png"; myImage.save( mRenderedImageFile, "PNG", 100 ); return compareImages( theTestName, theMismatchCount ); }
void SkillPanel::buildGui(QString img,QString name, QString des){ //add picture QPixmap myImage(img); img1 = this->addPixmap(myImage); img1->setPos(90,0); //font list QFont serifFont("Times", 12, QFont::Bold); //add name skillNameItem1 = this->addText(name); skillNameItem1->setPos(80,27); skillNameItem1->setFont(serifFont); //add strength Description1 = this->addText(des); Description1->setPos(0, 67); }
int main() { PPMManager myImage("my_ppm.ppm"); ImageBuffer buffer(10, 10, ImageBuffer::IMAGE_RGB); int size = buffer.width() * buffer.height(); int index; // Puts all pixels on white. std::cout << size << std::endl; for (int i = 0; i < size * 3; i++) { buffer.data()[i] = 0xFF; } // Sets type to text. myImage.setType(PPMManager::PPM_TEXT); myImage.setMaxColor(255); // Writes image myImage.writeBuffer(buffer); return 0; }
int main() { std::cout<<"working"<<std::endl; ImageWrite myImage(200,200); return EXIT_SUCCESS; }
bool QgsRenderChecker::runTest( QString theTestName, unsigned int theMismatchCount ) { if ( mExpectedImageFile.isEmpty() ) { qDebug( "QgsRenderChecker::runTest failed - Expected Image File not set." ); mReport = "<table>" "<tr><td>Test Result:</td><td>Expected Result:</td></tr>\n" "<tr><td>Nothing rendered</td>\n<td>Failed because Expected " "Image File not set.</td></tr></table>\n"; return false; } // // Load the expected result pixmap // QImage myExpectedImage( mExpectedImageFile ); mMatchTarget = myExpectedImage.width() * myExpectedImage.height(); // // Now render our layers onto a pixmap // QImage myImage( myExpectedImage.width(), myExpectedImage.height(), QImage::Format_RGB32 ); myImage.setDotsPerMeterX( myExpectedImage.dotsPerMeterX() ); myImage.setDotsPerMeterY( myExpectedImage.dotsPerMeterY() ); myImage.fill( qRgb( 152, 219, 249 ) ); QPainter myPainter( &myImage ); myPainter.setRenderHint( QPainter::Antialiasing ); mpMapRenderer->setOutputSize( QSize( myExpectedImage.width(), myExpectedImage.height() ), myExpectedImage.logicalDpiX() ); QTime myTime; myTime.start(); mpMapRenderer->render( &myPainter ); mElapsedTime = myTime.elapsed(); myPainter.end(); // // Save the pixmap to disk so the user can make a // visual assessment if needed // mRenderedImageFile = QDir::tempPath() + QDir::separator() + theTestName + "_result.png"; myImage.save( mRenderedImageFile, "PNG", 100 ); //create a world file to go with the image... QFile wldFile( QDir::tempPath() + QDir::separator() + theTestName + "_result.wld" ); if ( wldFile.open( QIODevice::WriteOnly ) ) { QgsRectangle r = mpMapRenderer->extent(); QTextStream stream( &wldFile ); stream << QString( "%1\r\n0 \r\n0 \r\n%2\r\n%3\r\n%4\r\n" ) .arg( qgsDoubleToString( mpMapRenderer->mapUnitsPerPixel() ) ) .arg( qgsDoubleToString( -mpMapRenderer->mapUnitsPerPixel() ) ) .arg( qgsDoubleToString( r.xMinimum() + mpMapRenderer->mapUnitsPerPixel() / 2.0 ) ) .arg( qgsDoubleToString( r.yMaximum() - mpMapRenderer->mapUnitsPerPixel() / 2.0 ) ); } return compareImages( theTestName, theMismatchCount ); }
void TestQgsWcsPublicServers::test( ) { QStringList versions; // It may happen that server supports 1.1.1, but does not accept 1.1 (http://zeus.pin.unifi.it/gi-wcs/http) versions << "" << "1.0.0" << "1.1.0"; // empty for default QStringList servers; // Some (first) coverages do not advertize any supportedCRS and sever gives // error both with native CRS (EPSG::561005) and EPSG:4326 // MOD* coverages work OK servers << "http://argon.geogr.uni-jena.de:8080/geoserver/ows"; servers << "http://demo.geonode.org/geoserver/wcs"; servers << "http://demo.mapserver.org/cgi-bin/wcs"; servers << "http://demo.opengeo.org/geoserver/wcs"; // geobrain.laits.gmu.edu servers are quite slow servers << "http://geobrain.laits.gmu.edu/cgi-bin/gbwcs-dem"; servers << "http://geobrain.laits.gmu.edu/cgi-bin/ows8/wcseo"; servers << "http://geobrain.laits.gmu.edu/cgi-bin/wcs110"; servers << "http://geobrain.laits.gmu.edu/cgi-bin/wcs-all"; servers << "http://iceds.ge.ucl.ac.uk/cgi-bin/icedswcs"; servers << "http://motherlode.ucar.edu:8080/thredds/wcs/fmrc/NCEP/DGEX/Alaska_12km/NCEP-DGEX-Alaska_12km_best.ncd"; servers << "http://navigator.state.or.us/ArcGIS/services/Framework/Imagery_Mosaic2009/ImageServer/WCSServer"; servers << "http://nsidc.org/cgi-bin/atlas_north"; servers << "http://sedac.ciesin.columbia.edu/geoserver/wcs"; // Big and slow //servers << "http://webmap.ornl.gov/ogcbroker/wcs"; servers << "http://ws.csiss.gmu.edu/cgi-bin/wcs-t"; // Big and slow //servers << "http://ws.laits.gmu.edu/cgi-bin/wcs-all"; // Currently very slow or down //servers << "http://www.sogeo.ch/geoserver/wcs"; // Slow and erroneous //servers << "http://zeus.pin.unifi.it/gi-wcs/http"; foreach ( QString server, servers ) { QStringList myServerLog; myServerLog << "server:" + server; QString myServerDirName = server; myServerDirName.replace( QRegExp( "[:/]+" ), "." ); myServerDirName.replace( QRegExp( "\\.$" ), "" ); QgsDebugMsg( "myServerDirName = " + myServerDirName ); QDir myServerDir( mCacheDir.absolutePath() + QDir::separator() + myServerDirName ); QString myServerLogPath = myServerDir.absolutePath() + QDir::separator() + "server.log"; if ( QFileInfo( myServerLogPath ).exists() ) { QgsDebugMsg( "cache exists " + myServerDir.absolutePath() ); continue; } if ( !myServerDir.exists() ) { mCacheDir.mkdir( myServerDirName ); } foreach ( QString version, versions ) { QgsDebugMsg( "server: " + server + " version: " + version ); QgsDataSourceURI myServerUri; myServerUri.setParam( "url", server ); if ( !version.isEmpty() ) { myServerUri.setParam( "version", version ); } QgsWcsCapabilities myCapabilities; myCapabilities.setUri( myServerUri ); if ( !myCapabilities.lastError().isEmpty() ) { QgsDebugMsg( myCapabilities.lastError() ); myServerLog << "error: (version: " + version + ") " + myCapabilities.lastError().replace( "\n", " " ); continue; } QVector<QgsWcsCoverageSummary> myCoverages; if ( !myCapabilities.supportedCoverages( myCoverages ) ) { QgsDebugMsg( "Cannot get list of coverages" ); myServerLog << "error: (version: " + version + ") Cannot get list of coverages"; continue; } int myCoverageCount = 0; int myStep = myCoverages.size() / mMaxCoverages; int myStepCount = -1; foreach ( QgsWcsCoverageSummary myCoverage, myCoverages ) { QgsDebugMsg( "coverage: " + myCoverage.identifier ); // Go in steps to get more success/errors if ( myStepCount == -1 || myStepCount > myStep ) { myStepCount = 0; } else { myStepCount++; continue; } myCoverageCount++; if ( myCoverageCount > mMaxCoverages ) break; QString myPath = myServerDir.absolutePath() + QDir::separator() + myCoverage.identifier; if ( !version.isEmpty() ) { myPath += "-" + version; } QString myLogPath = myPath + ".log"; if ( QFileInfo( myLogPath ).exists() ) { QMap<QString, QString> log = readLog( myLogPath ); if ( !log.value( "identifier" ).isEmpty() && log.value( "error" ).isEmpty() ) continue; } QStringList myLog; myLog << "identifier:" + myCoverage.identifier; myCapabilities.describeCoverage( myCoverage.identifier ); myCoverage = myCapabilities.coverage( myCoverage.identifier ); // get described QgsDataSourceURI myUri = myServerUri; myUri.setParam( "identifier", myCoverage.identifier ); if ( myCoverage.times.size() > 0 ) { myUri.setParam( "time", myCoverage.times.value( 0 ) ); } myLog << "version:" + version; myLog << "uri:" + myUri.encodedUri(); int myWidth = 100; int myHeight = 100; if ( myCoverage.hasSize ) { myHeight = static_cast<int>( qRound( 1.0 * myWidth * myCoverage.height / myCoverage.width ) ); } myLog << QString( "hasSize:%1" ).arg( myCoverage.hasSize ); QgsRasterLayer * myLayer = new QgsRasterLayer( myUri.encodedUri(), myCoverage.identifier, "wcs", true ); if ( myLayer->isValid() ) { int myBandCount = myLayer->dataProvider()->bandCount(); myLog << "bandCount:" + QString::number( myBandCount ); if ( myBandCount > 0 ) { myLog << "srcType:" + QString::number( myLayer->dataProvider()->srcDataType( 1 ) ); QgsRasterBandStats myStats = myLayer->dataProvider()->bandStatistics( 1, QgsRasterBandStats::All, QgsRectangle(), myWidth * myHeight ); myLog << "min:" + QString::number( myStats.minimumValue ); myLog << "max:" + QString::number( myStats.maximumValue ); } QgsMapRenderer myMapRenderer; QList<QgsMapLayer *> myLayersList; myLayersList.append( myLayer ); QgsMapLayerRegistry::instance()->addMapLayers( myLayersList, false ); QMap<QString, QgsMapLayer*> myLayersMap = QgsMapLayerRegistry::instance()->mapLayers(); myMapRenderer.setLayerSet( myLayersMap.keys() ); myMapRenderer.setExtent( myLayer->extent() ); QImage myImage( myWidth, myHeight, QImage::Format_ARGB32_Premultiplied ); myImage.fill( 0 ); myMapRenderer.setOutputSize( QSize( myWidth, myHeight ), myImage.logicalDpiX() ); QPainter myPainter( &myImage ); myMapRenderer.render( &myPainter ); // Save rendered image QString myPngPath = myPath + ".png"; QgsDebugMsg( "myPngPath = " + myPngPath ); myImage.save( myPngPath ); // Verify data QSet<QString> myValues; // cannot be QSet<double> void *myData = myLayer->dataProvider()->readBlock( 1, myLayer->extent(), myWidth, myHeight ); if ( myData ) { int myType = myLayer->dataProvider()->dataType( 1 ); for ( int row = 0; row < myHeight; row++ ) { for ( int col = 0; col < myWidth; col++ ) { double value = myLayer->dataProvider()->readValue( myData, myType, row * myWidth + col ); QString valueStr = QString::number( value ); if ( !myValues.contains( valueStr ) ) myValues.insert( valueStr ); } } free( myData ); } QgsDebugMsg( QString( "%1 values" ).arg( myValues.size() ) ); myLog << QString( "valuesCount:%1" ).arg( myValues.size() ); // Verify image colors QSet<QRgb> myColors; for ( int row = 0; row < myHeight; row++ ) { for ( int col = 0; col < myWidth; col++ ) { QRgb color = myImage.pixel( col, row ); if ( !myColors.contains( color ) ) myColors.insert( color ); } } QgsDebugMsg( QString( "%1 colors" ).arg( myColors.size() ) ); myLog << QString( "colorsCount:%1" ).arg( myColors.size() ); } else { QgsDebugMsg( "Layer is not valid" ); myLog << "error:Layer is not valid"; } QFile myLogFile( myLogPath ); myLogFile.open( QIODevice::WriteOnly | QIODevice::Text ); QTextStream myStream( &myLogFile ); myStream << myLog.join( "\n" ); myLogFile.close(); QgsMapLayerRegistry::instance()->removeAllMapLayers(); }
//-------------------------------------------------------------- // Callback function to show different instructions pages void testApp::drawInstructionsPage(int & pageNum) { if (showInstructions) { int i = pageNum; switch (i) { case 0: { ofTrueTypeFont font; font.loadFont("verdana.ttf", 15, true, true); ofColor fontColor(255,255,255); ofPoint stimulusCenter(ofGetWindowWidth()/2, ofGetWindowHeight()/2); std::stringstream ss; ss << "Welcome to TELEPHONE REWIRED, an immersive audiovisual art installation and\n"; ss << "scientific experiment examining the role of oscillations in the brain and the future \n"; ss << "of human cognition. The lights and sound in the room are designed to mimic \n"; ss << "frequencies ordinarily created by neurons in your brain. After several minutes of \n"; ss << "experiencing TELEPHONE REWIRED your neurons will begin to synchronize with \n"; ss << "the installation, firing in a similar pattern. \n"; ss << "\n"; ss << "We invite you to participate in an experiment studying how this installation \n"; ss << "changes your EEG oscillations (brainwaves) and how it affects your perception, \n"; ss << "attention and memory. This will take about 6 minutes in this room and 5 more \n"; ss << "minutes at the desk outside.\n"; ss << "\n"; ss << "To participate in the experiment, please push the green button.\n"; string data1 = ss.str(); ofPushMatrix(); ofPushStyle(); ofRectangle bounds1 = font.getStringBoundingBox(data1, 0, 0); ofTranslate(-bounds1.width/2, -bounds1.height / 2, 0); ofSetColor(fontColor); font.drawString(data1, stimulusCenter.x, stimulusCenter.y); ofPopStyle(); ofPopMatrix(); break; } case 1: { ofTrueTypeFont font; font.loadFont("verdana.ttf", 15, true, true); ofColor fontColor(255,255,255); ofPoint stimulusCenter(ofGetWindowWidth()/2, ofGetWindowHeight()/2); ofImage myImage("zeo_pic.png"); myImage.draw(ofGetWindowWidth()/2, ofGetWindowHeight()/2+120, 250, 250); std::stringstream ss; ss << "TELEPHONE REWIRED measures and records your brain activity (EEG) using a Zeo \n"; ss << "headband monitor. Please put on the headband now, and keep it placed centrally \n"; ss << "on your forehead throughout the experiment (see picture). \n"; ss << "\n"; ss << "We are also studying how quickly you respond when words appear on the screen \n"; ss << "or play through the speakers. Please keep your hand on the green button \n"; ss << "throughout the experiment and press it as soon as you hear or see a word.\n"; ss << "\n"; ss << "Your memory of the words will also be tested at the desk outside, so please pay \n"; ss << "attention and remember as many as you can.\n"; ss << "\n"; ss << "Although you are participating in a scientific experiment, we hope you will also be \n"; ss << "able to enjoy the experience of altering your neuronal oscillations!\n"; ss << "\n"; ss << "Press the green button to continue.\n"; string data1 = ss.str(); ofPushMatrix(); ofPushStyle(); ofRectangle bounds1 = font.getStringBoundingBox(data1, 0, 0); ofTranslate(-bounds1.width/2, -bounds1.height / 2, 0); ofSetColor(fontColor); font.drawString(data1, stimulusCenter.x, stimulusCenter.y); ofPopStyle(); ofPopMatrix(); break; } case 2: { ofTrueTypeFont font; font.loadFont("verdana.ttf", 15, true, true); ofColor fontColor(255,255,255); ofPoint stimulusCenter(ofGetWindowWidth()/2, ofGetWindowHeight()/2); std::stringstream ss; ss << "Before you begin, make sure you are wearing the Zeo EEG headband and have \n"; ss << "your hand on the green button.\n"; ss << "\n"; ss << "When the screen indicates that you are done with this portion of the experiment, \n"; ss << "you can remove the EEG headband. Then you may go outside to complete the \n"; ss << "experiment with a survey on a different computer by entering the code below so \n"; ss << "that your answers can be linked with your brain activity (EEG).\n"; ss << "\n"; ss << "Your code number is: " << experimentGovernor.getParticipantID() << "\n"; ss << "Please write it down now.\n"; ss << "\n"; ss << "Telephone Rewired was created by:\n"; ss << "LoVid - http://lovid.org/\n"; ss << "Sean Montgomery - http://www.produceconsumerobot.com/\n"; ss << "Special thanks to Mitch Altman for sharing his Brain Machine entrainment patterns \n"; ss << "with the open source community.\n"; ss << "\n"; ss << "Push the green button to begin the experiment.\n"; string data1 = ss.str(); ofPushMatrix(); ofPushStyle(); ofRectangle bounds1 = font.getStringBoundingBox(data1, 0, 0); ofTranslate(-bounds1.width/2, -bounds1.height / 2, 0); ofSetColor(fontColor); font.drawString(data1, stimulusCenter.x, stimulusCenter.y); ofPopStyle(); ofPopMatrix(); break; } default: break; } } }