bool Syscall::loadResources(Stream& file, const char* aFilename) { bool hasResources = true; if(!file.isOpen()) hasResources = false; else { int len, pos; TEST(file.length(len)); TEST(file.tell(pos)); if(len == pos) hasResources = false; } if(!hasResources/* && aFilename != NULL*/) { resources.init(0); return true; } #define MATCH_BYTE(c) { DAR_UBYTE(b); if(b != c) { FAIL; } } MATCH_BYTE('M'); MATCH_BYTE('A'); MATCH_BYTE('R'); MATCH_BYTE('S'); DAR_UVINT(nResources); DAR_UVINT(rSize); resources.init(nResources); // rI is the resource index. int rI = 1; while(true) { DAR_UBYTE(type); if(type == 0) break; //dispose flag DAR_UVINT(size); LOG_RES("Type %i, size %i\n", type, size); switch(type) { case RT_BINARY: { #ifndef _android MemStream* ms = new MemStream(size); #else char* b = loadBinary(rI, size); MemStream* ms = new MemStream(b, size); #endif TEST(file.readFully(*ms)); ROOM(resources.dadd_RT_BINARY(rI, ms)); #ifdef _android checkAndStoreAudioResource(rI); #endif } break; case RT_UBIN: { int pos; MYASSERT(aFilename, ERR_RES_LOAD_UBIN); TEST(file.tell(pos)); #ifndef _android ROOM(resources.dadd_RT_BINARY(rI, new LimitedFileStream(aFilename, pos, size))); #else // Android loads ubins by using JNI. loadUBinary(rI, pos, size); ROOM(resources.dadd_RT_BINARY(rI, new LimitedFileStream( aFilename, pos, size, getJNIEnvironment(), getJNIThis()))); #endif TEST(file.seek(Seek::Current, size)); } break; case RT_PLACEHOLDER: ROOM(resources.dadd_RT_PLACEHOLDER(rI, NULL)); break; case RT_IMAGE: { MemStream b(size); TEST(file.readFully(b)); #ifndef _android // On all platforms except Android, we load and add // the image data. "dadd" means "delete and add", // and is defined in runtimes\cpp\base\ResourceArray.h RT_IMAGE_Type* image = loadImage(b); if(!image) BIG_PHAT_ERROR(ERR_IMAGE_LOAD_FAILED); ROOM(resources.dadd_RT_IMAGE(rI, image)); #else // On Android images are stored on the Java side. // Here we allocate a dummy array (real image is // in a table in Java) so that the resource handling, // like deleting resources, will work also on Android. // The actual image will be garbage collected on // Android when a resource is replaced in the Java table. ROOM(resources.dadd_RT_IMAGE(rI, new int[1])); int pos; file.tell(pos); loadImage( rI, pos - size, size, Base::gSyscall->getReloadHandle()); #endif } break; case RT_SPRITE: { DAR_USHORT(indexSource); DAR_USHORT(left); DAR_USHORT(top); DAR_USHORT(width); DAR_USHORT(height); DAR_SHORT(cx); DAR_SHORT(cy); #ifndef _android ROOM(resources.dadd_RT_IMAGE(rI, loadSprite(resources.get_RT_IMAGE(indexSource), left, top, width, height, cx, cy))); #endif } break; case RT_LABEL: { MemStream b(size); TEST(file.readFully(b)); ROOM(resources.dadd_RT_LABEL(rI, new Label((const char*)b.ptr(), rI))); } break; #ifdef LOGGING_ENABLED case 99: //testtype #define DUMP_UVI { DAR_UVINT(u); LOG_RES("u %i\n", u); } #define DUMP_SVI { DAR_SVINT(s); LOG_RES("s %i\n", s); } DUMP_UVI; DUMP_UVI; DUMP_UVI; DUMP_SVI; DUMP_SVI; DUMP_SVI; DUMP_SVI; DUMP_SVI; DUMP_SVI; break; #endif default: TEST(file.seek(Seek::Current, size)); } rI++; } if(rI != nResources + 1) { LOG("rI %i, nR %i\n", rI, nResources); BIG_PHAT_ERROR(ERR_RES_FILE_INCONSISTENT); } LOG_RES("ResLoad complete\n"); return true; }
void KBImageLoader::run() { QMutexLocker locker(&d->condLock); // we enter the loop with d->needImage==true, so we will immediately // try to load an image while (true) { if (d->quitRequested) break; if (d->needImage) { if ( d->fileIndex == (int)d->fileList.count() ) { if ( d->loop ) { d->fileIndex = 0; } else { d->needImage = false; emit(signalEndOfShow()); continue; } } d->needImage = false; d->condLock.unlock(); bool ok; do { ok = loadImage(); if ( !ok) invalidateCurrentImageName(); } while ( !ok && d->fileIndex < (int)d->fileList.count()); if ( d->fileIndex == (int)d->fileList.count() ) { emit(signalEndOfShow()); d->condLock.lock(); continue; } if ( !ok) { // generate a black dummy image d->texture = QImage(128, 128, QImage::Format_ARGB32); d->texture.fill(Qt::black); } d->condLock.lock(); d->fileIndex++; if ( !d->initialized) { d->haveImages = ok; d->initialized = true; } } else { // wait for new requests from the consumer d->imageRequest.wait(&d->condLock); } } }
//---------------------------------------------------- bool ofLoadImage(ofPixels & pix, const ofBuffer & buffer) { return loadImage(pix,buffer); }
void ImageProvider::toggleBlur() { if (loaderType == 0) { imgLoader->toggleBlur(); loadImage(true); } }
// Images loading/viewing void ImageProvider::next(int i) { if (!isLoading) { current = current < files->size() - i ? current + i : 0; loadImage(); } }
int main(int argc, char **argv){ if(argc!=3){ printf("Usage: convolution image.bmp block\n"); return 1; } const int gaussianKernelWidth = 5; const int gaussianKernelRadius = (gaussianKernelWidth-1)/2; float *gaussianKernel = new float[gaussianKernelWidth*gaussianKernelWidth]; buildGaussianKernel2D( 2, gaussianKernelRadius, gaussianKernel ); // float sobelX[9] = {-1.f,0.f,1.f,-2.f,0.f,2.f,-1.f,0.f,1.f}; int width, height, channels; unsigned char *data; bool res = loadImage(argv[1], &width, &height, &channels, &data); unsigned char *pixelsTemp = new unsigned char[width*height]; unsigned char *outTemp = new unsigned char[width*height]; unsigned char *out = new unsigned char[width*height*channels]; int blockSize = atoi(argv[2]); int blockCountX = width/blockSize; if(blockCountX<1){blockCountX=1;} int blockCountY = height/blockSize; if(blockCountY<1){blockCountY=1;} printf("blockSize %d blockCountX %d blockCountY %d\n",blockSize, blockCountX, blockCountY); timespec startTime; timespec endTime; // touch the memory for(int i=0; i<width*height*channels; i++){ out[i]=1; } clock_gettime(CLOCK_REALTIME,&startTime); for(int i=0; i<width*height*channels; i++){ out[i]=data[i]; } /* for(int c=0; c<channels; c++){ for(int i=0; i<width*height; i++){ pixelsTemp[i] = data[i*channels+c]; } // blur for(int blockX=0; blockX < blockCountX; blockX++){ for(int blockY=0; blockY < blockCountY; blockY++){ for(int x=blockX*blockSize; x<((blockX==blockCountX-1)?width:(blockX+1)*blockSize); x++){ for(int y=blockY*blockSize; y<((blockY==blockCountY-1)?height:(blockY+1)*blockSize); y++){ assert(x < width); assert(y < height); float accum = 0.f; for(int i=0; i<gaussianKernelWidth; i++){ for(int j=0; j<gaussianKernelWidth; j++){ int ix = clamp(x+i-gaussianKernelRadius, 0, width-1); int iy = clamp(y+j-gaussianKernelRadius, 0, height-1); accum += gaussianKernel[j*gaussianKernelWidth+i] * float(pixelsTemp[iy*width+ix]); } } outTemp[y*width+x] = accum; } } } } convolve2DClamped( width, height, pixelsTemp, gaussianKernelWidth, gaussianKernelWidth, gaussianKernel, outTemp ); // sobel for(int x=0; x<width; x++){ for(int y=0; y<height; y++){ float accum = 0.f; for(int i=0; i<3; i++){ for(int j=0; j<3; j++){ int ix = clamp(x+i-1, 0, width-1); int iy = clamp(y+j-1, 0, height-1); accum += sobelX[j*3+i] * float(outTemp[iy*width+ix]); } } pixelsTemp[y*width+x] = accum; } } convolve2DClamped( width, height, outTemp, 3, 3, sobelX, pixelsTemp ); // find max (3x3 kernel) for(int x=0; x<width; x++){ for(int y=0; y<height; y++){ unsigned char val = 0; for(int i=-1; i<=1; i++){ for(int j=-1; j<=1; j++){ int ix = clamp(x+i, 0, width-1); int iy = clamp(y+j, 0, height-1); val = std::max( val, pixelsTemp[(iy*width)+ix]); } } outTemp[(y*width)+x] = (pixelsTemp[(y*width)+x]==val)? 255 : 0; } } for(int i=0; i<width*height; i++){ out[i*channels+c] = outTemp[i]; //out[i*channels+c] = pixelsTemp[i]; } } */ clock_gettime(CLOCK_REALTIME,&endTime); timespec diff_serial; diff_serial.tv_sec=endTime.tv_sec - startTime.tv_sec; diff_serial.tv_nsec=endTime.tv_nsec - startTime.tv_nsec; std::cout << "Serial Code Runtime: " << ((double)diff_serial.tv_sec + ((double)diff_serial.tv_nsec/1E9)) << std::endl; double timeSec = ((double)diff_serial.tv_sec + ((double)diff_serial.tv_nsec/1E9)); std::cout << timeSec << std::endl; std::cout << (double(width*height*channels)/timeSec) << std::endl; std::cout << (double(width*height*channels)/timeSec)/(1073741824.f) << std::endl; res = saveImage("out.bmp", width, height, channels, out); res = saveImage("in.bmp", width, height, channels, data); delete[] pixelsTemp; delete[] outTemp; delete[] out; return 0; }
int main(void) { GLFWwindow* window; window = init("Transparency", 640, 480); if(!window) { return -1; } glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glm::mat4 proj = glm::perspective(glm::radians(45.0f), (float)640/(float)480, 0.1f, 1000.0f); glm::mat4 model1, model2, model3; // Cube 1 and 2 will be transparent, cube 3 not model1 = glm::translate(model1, glm::vec3(0.5f, 0.0f, -1.0f)); model2 = glm::translate(model2, glm::vec3(0.0f, 0.5f, -2.0f)); model3 = glm::translate(model3, glm::vec3(0.0f, 0.0f, -3.0f)); glm::mat4 view; view = glm::translate(view, glm::vec3(0.0f, 0.0f, -4.0f)); GLuint vertex = createShader(VERTEX_SRC, GL_VERTEX_SHADER); if(!vertex) { return -1; } GLuint fragment = createShader(FRAGMENT_SRC, GL_FRAGMENT_SHADER); if(!fragment) { return -1; } GLuint program = createShaderProgram(vertex, fragment); if(!program) { return -1; } bool result = linkShader(program); if(!result) { return -1; } result = validateShader(program); if(!result) { return -1; } glDetachShader(program, vertex); glDeleteShader(vertex); glDetachShader(program, fragment); glDeleteShader(fragment); glUseProgram(program); GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); GLuint vbo; glGenBuffers(1, &vbo); float vertices[] = { // x y z r g b u v -0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, -0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, -0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, -0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, -0.5f, -0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, -0.5f, -0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, -0.5f, 0.5f, -0.5f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }; glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glEnableVertexAttribArray(0); // position glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), 0); glEnableVertexAttribArray(1); // color glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(3 * sizeof(GLfloat))); glEnableVertexAttribArray(2); // texture coordinates glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(6 * sizeof(GLfloat))); int w, h; GLuint textureTrans = loadImage("transparent.png", &w, &h, 0, true); // GL_TEXTURE0 if(!textureTrans) { return -1; } GLuint textureOpaq = loadImage("opaque.png", &w, &h, 0, true); // GL_TEXTURE0 if(!textureOpaq) { return -1; } glUniform1i(glGetUniformLocation(program, "tex"), 0); // GL_TEXTURE0 GLint viewUL = glGetUniformLocation(program, "view"); glUniformMatrix4fv(viewUL, 1, GL_FALSE, glm::value_ptr(view)); GLint projUL = glGetUniformLocation(program, "projection"); glUniformMatrix4fv(projUL, 1, GL_FALSE, glm::value_ptr(proj)); GLint modelUL = glGetUniformLocation(program, "model"); glClearColor(0.75f, 0.75f, 0.75f, 1.0f); while(!glfwWindowShouldClose(window)) { // Clear (note the addition of GL_DEPTH_BUFFER_BIT) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // We have to sort the objects, rendering the backmost objects first // in this example, model1 is in front of model2, which is in front of model3 // and model3 is the only one using the opaque texture // (This way we can avoid the sorting, making the example a bit easier to follow) glBindTexture(GL_TEXTURE_2D, textureOpaq); glUniformMatrix4fv(modelUL, 1, GL_FALSE, glm::value_ptr(model3)); glDrawArrays(GL_TRIANGLES, 0, 36); glBindTexture(GL_TEXTURE_2D, textureTrans); glUniformMatrix4fv(modelUL, 1, GL_FALSE, glm::value_ptr(model2)); glDrawArrays(GL_TRIANGLES, 0, 36); glUniformMatrix4fv(modelUL, 1, GL_FALSE, glm::value_ptr(model1)); glDrawArrays(GL_TRIANGLES, 0, 36); glfwSwapBuffers(window); glfwPollEvents(); } // Clean up glDeleteBuffers(1, &vbo); glDeleteVertexArrays(1, &vao); glDeleteTextures(1, &textureTrans); glDeleteTextures(1, &textureOpaq); glfwTerminate(); return 0; }
void MenuBook::loadBook() { if (book_loaded) return; // Read data from config file FileParser infile; // @CLASS MenuBook|Description of books in books/ if (infile.open(book_name)) { while (infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; infile.val = infile.val + ','; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { int x = popFirstInt(infile.val); int y = popFirstInt(infile.val); closeButton->setBasePos(x, y); } // @ATTR background|string|Filename for the background image. else if (infile.key == "background") { setBackground(popFirstString(infile.val)); } else if (infile.section == "") { infile.error("MenuBook: '%s' is not a valid key.", infile.key.c_str()); } if (infile.new_section) { // for sections that are stored in collections, add a new object here if (infile.section == "text") { text.push_back(NULL); textData.push_back(""); textColor.push_back(Color()); justify.push_back(0); textFont.push_back(""); size.push_back(Rect()); } else if (infile.section == "image") { image.push_back(NULL); image_dest.push_back(Point()); } } if (infile.section == "text") loadText(infile); else if (infile.section == "image") loadImage(infile); } infile.close(); } // setup image dest for (unsigned i=0; i < image.size(); i++) { image[i]->setDest(image_dest[i]); } // render text to surface for (unsigned i=0; i<text.size(); i++) { font->setFont(textFont[i]); Point pSize = font->calc_size(textData[i], size[i].w); Image *graphics = render_device->createImage(size[i].w, pSize.y); if (justify[i] == JUSTIFY_CENTER) font->render(textData[i], size[i].w/2, 0, justify[i], graphics, size[i].w, textColor[i]); else if (justify[i] == JUSTIFY_RIGHT) font->render(textData[i], size[i].w, 0, justify[i], graphics, size[i].w, textColor[i]); else font->render(textData[i], 0, 0, justify[i], graphics, size[i].w, textColor[i]); text[i] = graphics->createSprite(); graphics->unref(); } align(); book_loaded = true; }
Image::Image(const QString& fileName) { loadImage(fileName); }
CustomGraphicsView::CustomGraphicsView(QWidget *parent) : QGraphicsView(parent) { //Set scene. this->setScene(&m_graphicsScene); //Set width to default View width m_nWidth = this->geometry().width(); //Set width to default View height m_nHeight = this->geometry().height(); //View X-offset m_nOffsetX = 20; //View Y-offset m_nOffsetY = 20; //Gap between Items. m_nItemSpace = 10; m_nRow = 0; m_nColoumn = 0; m_nMaxColumn = 0; m_sceneRect.setWidth(m_nWidth); m_graphicsScene.setSceneRect(m_sceneRect); m_itemTransformation = Qt::SmoothTransformation; hXPSConvert = LoadLibrary(L"XpsConvertQt.dll"); docConvertThread = new DocConverterThread(this); docConvertThread->start(); connect(docConvertThread, SIGNAL(addItem(QString)), this, SLOT(addItemToScene(QString))); //Set Rendering hint flags of GraphicsView. this->setRenderHints (QPainter::TextAntialiasing); this->setDragMode(QGraphicsView::RubberBandDrag); viewThread = new ViewWorkerThread(this); viewThread->start(); connect(this, SIGNAL(loadImage(QList<QGraphicsItem*>)), viewThread, SLOT(prepareImage(QList<QGraphicsItem*>))); connect(viewThread, SIGNAL(updateItem(CustomItem* )), this, SLOT(updateItemImage(CustomItem*))); //Set Cache mode flag. //this->setCacheMode (QGraphicsView::NoCache); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateItem())); timer->setSingleShot(true); //Set Viewport Update mode of the view. this->setViewportUpdateMode (QGraphicsView::SmartViewportUpdate); connect(this->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onScrollValueChanged(int))); }
bool ofImage_<PixelType>::loadImage(const ofFile & file){ return loadImage(file.getAbsolutePath()); }
texture4::texture4( string _f ) : texUnit( 0 ), img( 0 ), name( _f ), width( 0 ), height( 0 ) { jAssert( file::ioFile::exists( _f ) ); image magickImg( name.fileFullName ); loadImage( magickImg ); }
texture4::texture4( file::ioFile _f ) : texUnit( 0 ), img( 0 ), name( _f.getFilename() ), width( 0 ), height( 0 ) { jAssert( _f.exists() ); image magickImg( name.fileFullName ); loadImage( magickImg ); }
texture4::texture4( image &c ) : texUnit( 0 ), img( 0 ), name(""), width( 0 ), height( 0 ) { loadImage( c ); }
void GraphView::resizeEvent(QResizeEvent* e){ QWidget::resizeEvent(e); loadImage(im); }
int main(int argc, char *argv[]) { if (argc <= 2) { printHelp (); return 0; } gvfsegPara segpara; // set default values segpara.channelNo = 2; segpara.fusionThreshold = 3; segpara.diffusionIteration = 15; segpara.minRegion = 50; segpara.sigma = 1.0; /* Read arguments */ V3DLONG c; static char optstring[] = "h:i:o:c:f:m:d:s:"; opterr = 0; while ((c = getopt (argc, argv, optstring)) != -1) { switch (c) { case 'h': printHelp (); return 0; break; case 'i': if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-') { fprintf (stderr, "Found illegal or NULL parameter for the option -i.\n"); return 1; } segpara.infilename = optarg; break; case 'o': if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-') { fprintf (stderr, "Found illegal or NULL parameter for the option -o.\n"); return 1; } segpara.outfilename = optarg; break; case 'c': if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-') { fprintf (stderr, "Found illegal or NULL parameter for the option -c.\n"); return 1; } segpara.channelNo = atoi (optarg); // should be 0, 1, 2,... if (segpara.channelNo < 0) { fprintf (stderr, "Illeagal channelNo found! It must be >=0.\n"); return 1; } break; case 'f': if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-') { fprintf (stderr, "Found illegal or NULL parameter for the option -c.\n"); return 1; } segpara.fusionThreshold = atoi (optarg); // should be 0, 1, 2,... if (segpara.fusionThreshold < 0) { fprintf (stderr, "Illeagal channelNo found! It must be >=0.\n"); return 1; } break; case 'm': if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-') { fprintf (stderr, "Found illegal or NULL parameter for the option -c.\n"); return 1; } segpara.minRegion = atoi (optarg); // should be 0, 1, 2,... if (segpara.minRegion < 0) { fprintf (stderr, "Illeagal channelNo found! It must be >=0.\n"); return 1; } break; case 'd': if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-') { fprintf (stderr, "Found illegal or NULL parameter for the option -c.\n"); return 1; } segpara.diffusionIteration = atoi (optarg); // should be 0, 1, 2,... if (segpara.diffusionIteration < 0) { fprintf (stderr, "Illeagal channelNo found! It must be >=0.\n"); return 1; } break; case 's': if (strcmp (optarg, "(null)") == 0 || optarg[0] == '-') { fprintf (stderr, "Found illegal or NULL parameter for the option -c.\n"); return 1; } segpara.sigma = atof (optarg); if (segpara.sigma < 0) { fprintf (stderr, "Illeagal channelNo found! It must be >=0.\n"); return 1; } break; } } if (optind < argc) printf ("Stop parsing arguments list. Left off at %s\n", argv[optind]); unsigned char * inimg1d = 0; /* note that this variable must be initialized as NULL. */ V3DLONG * sz = 0; /* note that this variable must be initialized as NULL. */ int datatype = 0; ////////////////////////////////////////////////////////////////////////////////// ////20080920 by RZC for win32(mingw): to get rid of error: crosses initialization Vol3DSimple <unsigned char> *img3d = 0; V3DLONG *data_sz = 0; Vol3DSimple <unsigned short int> *outimg3d = 0; bool b_res = false; ////////////////////////////////////////////////////////////////////////////////// /* Read file and display some information. */ if (loadImage(segpara.infilename, inimg1d, sz, datatype)!=true) { fprintf (stderr, "Error happens in reading the file [%s]. Exit. \n", segpara.infilename); goto Label_exit; } //Vol3DSimple <unsigned char> *img3d = new Vol3DSimple <unsigned char> (inimg1d, sz, segpara.channelNo); //input 3D image img3d = new Vol3DSimple <unsigned char> (inimg1d, sz, segpara.channelNo); //input 3D image if (inimg1d) {delete []inimg1d; inimg1d=0;} //V3DLONG *data_sz = new V3DLONG [3]; data_sz = new V3DLONG [3]; V3DLONG len; data_sz[0]= img3d->sz0(); data_sz[1]= img3d->sz1(); data_sz[2]= img3d->sz2(); len = data_sz[0] * data_sz[1] * data_sz[2]; printf("%d, %d, %d\n", data_sz[0], data_sz[1], data_sz[2]); //Vol3DSimple <unsigned short int> *outimg3d = new Vol3DSimple <unsigned short int> (data_sz[0], data_sz[1], data_sz[2]); //output 3D image outimg3d = new Vol3DSimple <unsigned short int> (data_sz[0], data_sz[1], data_sz[2]); //output 3D image //now do computation //bool b_res = gvfCellSeg(img3d, outimg3d, segpara); b_res = gvfCellSeg(img3d, outimg3d, segpara); /* making labels continous and reordering the label of the nuclei */ /* save files */ if (b_res) { V3DLONG sz[4]; sz[0] = img3d->sz0(); sz[1]= img3d->sz1(); sz[2]= img3d->sz2(); sz[3] = 1; if (saveImage(segpara.outfilename,(const unsigned char *) outimg3d->getData1dHandle(), sz, sizeof(unsigned short int))!=true) { fprintf(stderr, "Error happens in file writing. Exit. \n"); } } else { fprintf(stderr, "Fail to generate the cell segmentation results. \n"); } /* clean all workspace variables */ Label_exit: if (sz) {delete [] sz; sz=0;} if (data_sz) {delete [] data_sz; data_sz =0;} if (outimg3d) {delete outimg3d; outimg3d =0;} if (img3d) {delete img3d; img3d=0;} return 0; }
void Level::loadTextures() { int numtextures = 14; GLuint* texture = new GLuint[numtextures]; // allocate a texture name glGenTextures(numtextures, texture); cellTextures[OPEN] = texture[0]; loadImage("open.raw", cellTextures[OPEN]); cellTextures[FULL] = texture[1]; loadImage("full.raw", cellTextures[FULL]); cellTextures[TLCCCORNER] = texture[2]; loadImage("tlcccorner.raw", cellTextures[TLCCCORNER]); cellTextures[TRCCCORNER] = texture[3]; loadImage("trcccorner.raw", cellTextures[TRCCCORNER]); cellTextures[BLCCCORNER] = texture[4]; loadImage("blcccorner.raw", cellTextures[BLCCCORNER]); cellTextures[BRCCCORNER] = texture[5]; loadImage("brcccorner.raw", cellTextures[BRCCCORNER]); cellTextures[TLCVCORNER] = texture[6]; loadImage("tlcvcorner.raw", cellTextures[TLCVCORNER]); cellTextures[TRCVCORNER] = texture[7]; loadImage("trcvcorner.raw", cellTextures[TRCVCORNER]); cellTextures[BLCVCORNER] = texture[8]; loadImage("blcvcorner.raw", cellTextures[BLCVCORNER]); cellTextures[BRCVCORNER] = texture[9]; loadImage("brcvcorner.raw", cellTextures[BRCVCORNER]); cellTextures[LEFT] = texture[10]; loadImage("left.raw", cellTextures[LEFT]); cellTextures[RIGHT] = texture[11]; loadImage("right.raw", cellTextures[RIGHT]); cellTextures[BOTTOM] = texture[12]; loadImage("bottom.raw", cellTextures[BOTTOM]); cellTextures[TOP] = texture[13]; loadImage("top.raw", cellTextures[TOP]); delete[] texture; }
/** * \fn Worms* createWorms(const char *file, SDL_Color* couleur) * \brief Créé et initialise une structure worms. * * \param[in] name, chaine de caractères correspondant au nom du worms * \param[in] couleur, couleur de l'équipe du worms * * \returns pointeur vers la structure worms créée, NULL si echec */ Worms* createWorms(Equipe* team, char* name, SDL_Color* couleur) { Worms* worms = NULL; SDL_Surface* moveRight = NULL; SDL_Surface* moveLeft = NULL; SDL_Rect clip = initRect(445, 28, WIDTHSPRITEMOVE, HIGHTSPRITEMOVE); char strVie[10]; fprintf(logFile, "createWorms : START :\n\n"); worms = (Worms*)my_malloc(sizeof(Worms)); if (worms == NULL) { fprintf(logFile, "createWorms : FAILURE, allocating memory to worms.\n\n"); decreaseMalloc(); return NULL; } moveLeft = loadImage("../assets/sprites/moveLeft.png"); if (moveLeft != NULL) { worms->wormsSurfaceLeft = animationSprite(moveLeft, NULL, 15, 14); my_freeSurface(moveLeft); } moveRight = loadImage("../assets/sprites/moveRight.png"); if (moveRight != NULL) { worms->wormsSurfaceRight = animationSprite(moveRight, NULL, 15, 0); my_freeSurface(moveRight); } if (worms->wormsSurfaceLeft == NULL || worms->wormsSurfaceRight == NULL) { fprintf(logFile, "createWorms : FAILURE, createRGBSurface : %s.\n\n", SDL_GetError()); destroyWorms(&worms, 1); decreaseMalloc(); return NULL; } worms->wormsSurfaceTomb = loadImage("../assets/pictures/Tombe2_SD.png"); if (worms->wormsSurfaceTomb == NULL) { fprintf(logFile, "createWorms : FAILURE, loadImage.\n\n"); destroyWorms(&worms, 1); decreaseMalloc(); return NULL; } //initialisation des variables autres worms->vie = 100; sprintf(strVie, " %d ", worms->vie); worms->color = couleur; strcpy(worms->nom, name); worms->texteLifeSurface = my_RenderText_Blended(globalVar.FontName[0], strVie, *(worms->color)); worms->texteNameSurface = my_RenderText_Blended(globalVar.FontName[0], worms->nom, *(worms->color)); if (worms->texteLifeSurface == NULL || worms->texteNameSurface == NULL) { fprintf(logFile, "createWorms : FAILURE, texteSurface.\n\n"); destroyWorms(&worms, 1); return NULL; } //Initialisations liees a l'image du worms clip.x = 300; clip.y = 100; clip.w = worms->wormsSurfaceRight->w; clip.h = worms->wormsSurfaceRight->h; if ((worms->wormsObject = KaamInitObject(worms->wormsSurfaceRight, 0.0, 0.0, DOWN, 0)) == NULL) { fprintf(logFile, "createWorms : FAILURE, KaamInitObject.\n\n"); destroyWorms(&worms, 1); return NULL; } //worms->invent = initInvent(Worms* worms); A FAIRE worms->indexAnim = 0; worms->random = 0; worms->randomCounter = 0; worms->dirSurface = RIGHT; worms->arme = NULL; worms->team = team; worms->shotCounter = 0; //Enregistrement log fprintf(logFile, "\ncreateWorms : SUCCESS.\n\n"); return worms; }
ImageDecoder *Texture::loadImage(const Common::UString &name, ::Aurora::FileType &type) { return loadImage(name, type, 0); }
/** * \fn void animationWorms(Worms* pWorms, int indexFrameAnim, enum DIRECTION direction, int random) * \brief Realise les animations de deplacement. * * \param[in] pWorms, worms a animer * \param[in] indexFrameAnim, index de la frame a afficher pour l'animation en cours * \param[in] direction, direction du deplacement * \returns 1 = affichage frame OK, 0 = problem copy frame */ int animationWorms(Worms* pWorms, int indexFrameAnim, enum DIRECTION direction, int random) { SDL_Surface* moveRight = NULL; SDL_Surface* moveLeft = NULL; SDL_Surface* randomSurface = NULL; if (random > 0) { switch (direction) { case RIGHT: if (random == 1) { randomSurface = loadImage("../assets/sprites/wormsRandom1R.png"); pWorms->wormsObject->objectSurface = animationSprite(randomSurface, pWorms->wormsObject->objectSurface, 6, indexFrameAnim); } else { randomSurface = loadImage("../assets/sprites/wormsRandom2R.png"); pWorms->wormsObject->objectSurface = animationSprite(randomSurface, pWorms->wormsObject->objectSurface, 8, indexFrameAnim); } if (randomSurface != NULL) my_freeSurface(randomSurface); break; case LEFT: if (random == 1) { randomSurface = loadImage("../assets/sprites/wormsRandom1.png"); pWorms->wormsObject->objectSurface = animationSprite(randomSurface, pWorms->wormsObject->objectSurface, 6, indexFrameAnim); } else { randomSurface = loadImage("../assets/sprites/wormsRandom2.png"); pWorms->wormsObject->objectSurface = animationSprite(randomSurface, pWorms->wormsObject->objectSurface, 8, indexFrameAnim); } if (randomSurface != NULL) my_freeSurface(randomSurface); break; } } else { switch (direction) { case RIGHT: moveRight = loadImage("../assets/sprites/moveRight.png"); pWorms->wormsObject->objectSurface = animationSprite(moveRight, pWorms->wormsObject->objectSurface, 15, indexFrameAnim); if (moveRight != NULL) my_freeSurface(moveRight); break; case LEFT: moveLeft = loadImage("../assets/sprites/moveLeft.png"); pWorms->wormsObject->objectSurface = animationSprite(moveLeft, pWorms->wormsObject->objectSurface, 15, indexFrameAnim); if (moveLeft != NULL) my_freeSurface(moveLeft); break; case UP: break; } } return 0; }
void ImageProvider::goTo() { current = QInputDialog::getInt(wnd, "Go to", "Go to:", current, 0, files->size()) - 1; loadImage(); }
TEST_F(BitmapImageTest, icoHasWrongFrameDimensions) { loadImage("/LayoutTests/fast/images/resources/wrong-frame-dimensions.ico"); // This call would cause crash without fix for 408026 imageForDefaultFrame(); }
void ImageProvider::cop() { io->cop(files->value(current)); files->removeAt(current); loadImage(); }
void RefImage::initThumbItem() { connect(thumbItem(),SIGNAL(blacklistItem()),this,SLOT(blacklistItem())); connect(thumbItem(),SIGNAL(imageLoadRequest()),this,SLOT(loadImage())); connect(thumbItem(),SIGNAL(cancelDownload()),this,SLOT(cancelDownload())); }
int main(){ printf("\n====================================================================\n"); printf("This program is able to simulate the diffusion of heat\n"); printf("across a metal plate of size %i x %i\n", ENV_SIZE_X, ENV_SIZE_Y); printf("====================================================================\n"); //========================================================================== //--------------------------SYSTEM INITIALIZATIONS-------------------------- //========================================================================== // initialize random seed srand(time(NULL)); // force print all outputs (remove stdout buffer) setbuf(stdout, NULL); // initialize pgplot window if (!cpgopen("/XWINDOW")) errorCase(ERR_PGPLOT); cpgpap(0.0, 0.6); // set window size cpgsubp(1,3); // subdivide window into panels // heatmap cpgpanl(1,1); cpgsvp(0.0, 1.0, 0.0, 1.0); cpgswin(0, ENV_SIZE_X, 0, ENV_SIZE_Y); // flux plot cpgpanl(1,2); cpgsvp(0.08, 0.92, 0.08, 0.92); cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, FLUX_PLOT_Y1, FLUX_PLOT_Y2); cpgbox("ABCINTS", 0.0, 0, "ABCINTS", 0.0, 0); cpglab("Time", "Flux", ""); // heat plot cpgpanl(1,3); cpgsvp(0.08, 0.92, 0.08, 0.92); cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, LINE_PLOT_Y1, LINE_PLOT_Y2); cpgbox("ABCINTS", 0.0, 0, "ABCINTS", 0.0, 0); cpglab("Time", "Total Heat", ""); // initialize color table for pgplot display float rl[9] = {-0.5, 0.0, 0.17, 0.33, 0.50, 0.67, 0.83, 1.0, 1.7}; float rr[9] = { 0.0, 0.0, 0.0, 0.0, 0.6, 1.0, 1.0, 1.0, 1.0}; float rg[9] = { 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.6, 0.0, 1.0}; float rb[9] = { 0.0, 0.3, 0.8, 1.0, 0.3, 0.0, 0.0, 0.0, 1.0}; cpgctab(rl, rr, rg, rb, 512, 1.0, 0.5); cpgscr(10, 0.0, 0.0, 1.0); cpgscr(11, 1.0, 0.0, 0.0); cpgsfs(3); //========================================================================== //--------------------------VARIABLE INITIALIZATIONS------------------------ //========================================================================== // generic variables int i, j, k; // counters // simulation environment float** simEnvEven = allocateArray2D(ENV_SIZE_X, ENV_SIZE_Y); float** simEnvOdd = allocateArray2D(ENV_SIZE_X, ENV_SIZE_Y); float* simLocal = allocateArray1D(5); // mnist handwritten numbers float** mnistDatabase = readCSV("mnist_train_100.csv", 100, 785); for (i=0; i<100; i++) for (j=0; j<785; j++) mnistDatabase[i][j] = mnistDatabase[i][j]/255.0; // current location and time int x,y,z; int t, tGlobal; // student number int studentNumbRaw; int studentNumbWorking; int studentNumb[7]; // rates float rateDiff = 0.2; float delta; // flux variables float flux; float fluxTotal; float fluxAverage; float fluxHeat; float totalHeat; int x1, x2, y1, y2; // background heat float bgHeat; // tracking variables float totalHeatOld; float totalHeatPre; float tGlobalOld; float fluxOld; // pgplot variables float* plotImg = allocateArray1D(ENV_SIZE_TOTAL); float TR[6] = {0, 0, 1, ENV_SIZE_Y, -1, 0}; float plotMinBound = 0; float plotMaxBound = 1; //========================================================================== //--------------------------------SETUP------------------------------------- //========================================================================== // ask for student number printf("Please enter your student number:\n"); if (scanf("%i", &studentNumbRaw) == 0) errorCase(ERR_INVALID_INPUT); studentNumbWorking = studentNumbRaw; for (i=0; i<SN_LENGTH; i++){ studentNumb[6-i] = studentNumbWorking%10; studentNumbWorking /= 10; } printf("\nYour student number is:\n"); for (i=0; i<SN_LENGTH; i++) printf("%i", studentNumb[i]); printf("\n\n"); // set and print diffusion rate based on last digit of student number rateDiff = ((((float)(studentNumb[6]))/10.0)*0.19)+0.01; printf("Your Diffusion Rate is: \n%f\n\n", rateDiff); // set and print background heat added based on last 4 digits of student number studentNumbRaw -= 1410000; bgHeat = ((float)((studentNumbRaw%97)%10)); bgHeat += ((float)((studentNumbRaw%101)%8))*10; bgHeat /= 100; printf("Your Background Heat is: \n%f\n\n", bgHeat*100); // set and print domain for calculating flux // x1, y1 based on last four digits of student number x1 = studentNumbRaw % ENV_SIZE_X; y1 = studentNumbRaw % ENV_SIZE_Y; // x2, y2 based on last four digits of student number x2 = x1 + (studentNumbRaw % (97)); if (x2 >= ENV_SIZE_X) x2 = ENV_SIZE_X - 1; y2 = y1 + (studentNumbRaw % (29)); if (y2 >= ENV_SIZE_Y) y2 = ENV_SIZE_Y - 1; printf("Your Domain is: \n(%i, %i) X (%i, %i)\n\n", x1, y1, x2, y2); // environment initialization: // select digits and place into environment for (i=0; i<SN_LENGTH; i++){ if (studentNumb[i] == 0) z = 0; else if (studentNumb[i] == 1) z = 13; else if (studentNumb[i] == 2) z = 27; else if (studentNumb[i] == 3) z = 33; else if (studentNumb[i] == 4) z = 44; else if (studentNumb[i] == 5) z = 55; else if (studentNumb[i] == 6) z = 60; else if (studentNumb[i] == 7) z = 71; else if (studentNumb[i] == 8) z = 81; else z = 89; for (x=0; x<28; x++) for (y=0; y<28; y++) { simEnvEven[x+(i*28)+1][y+1] = mnistDatabase[z][y*28+x] + bgHeat; if (simEnvEven[x+(i*28)+1][y+1] > 1.0) simEnvEven[x+(i*28)+1][y+1] = 1.0; } } //========================================================================== //--------------------------ACTUAL CODE------------------------------------- //========================================================================== // initialize display fixBoundaryConditions(simEnvEven); copyArray2D(simEnvEven, simEnvOdd, ENV_SIZE_X, ENV_SIZE_Y); loadImage(simEnvEven, plotImg); cpgpanl(1,1); cpgsvp(0.0, 1.0, 0.0, 1.0); cpgswin(0, ENV_SIZE_X, 0, ENV_SIZE_Y); cpgimag(plotImg, ENV_SIZE_Y, ENV_SIZE_X, 1, ENV_SIZE_Y, 1, ENV_SIZE_X, plotMinBound, plotMaxBound, TR); cpgrect(x1, x2, y1, y2); // initialize trackers tGlobalOld = 0; fluxOld = 0; totalHeatOld = 0; for (x=x1; x<=x2; x++) for (y=y1; y<=y2; y++) totalHeatOld += simEnvEven[x][y]; // initial delay to visualize starting matrix for (t=0; t<500000000; t++){} t = 0; tGlobal = 0; flux = 0; fluxAverage = 0; fluxTotal = 0; while(1){ flux = 0; cpgpanl(1,1); cpgsvp(0.0, 1.0, 0.0, 1.0); cpgswin(0, ENV_SIZE_X, 0, ENV_SIZE_Y); // calculate heat changes using numeric methods fixBoundaryConditions(simEnvEven); //simEnvEven[50][15] = 100; //simEnvEven[60][15] = -10; copyArray2D(simEnvEven, simEnvOdd, ENV_SIZE_X, ENV_SIZE_Y); for (x=1; x<(ENV_SIZE_X-1); x++) for (y=1; y<(ENV_SIZE_Y-1); y++) if ((x+y)%2 == 0) { delta = rateDiff*(simEnvEven[x][y+1] - 2*simEnvEven[x][y] + simEnvEven[x][y-1]); simEnvOdd[x][y] += delta; if (INSIDE_BOX) flux += delta; delta = rateDiff*(simEnvEven[x+1][y] - 2*simEnvEven[x][y] + simEnvEven[x-1][y]); simEnvOdd[x][y] += delta; if (INSIDE_BOX) flux += delta; } for (x=1; x<(ENV_SIZE_X-1); x++) for (y=1; y<(ENV_SIZE_Y-1); y++) if ((x+y)%2 == 1) { delta = rateDiff*(simEnvOdd[x][y+1] - 2*simEnvOdd[x][y] + simEnvOdd[x][y-1]); simEnvOdd[x][y] += delta; if (INSIDE_BOX) flux += delta; delta = rateDiff*(simEnvOdd[x+1][y] - 2*simEnvOdd[x][y] + simEnvOdd[x-1][y]); simEnvOdd[x][y] += delta; if (INSIDE_BOX) flux += delta; } loadImage(simEnvOdd, plotImg); cpgimag(plotImg, ENV_SIZE_Y, ENV_SIZE_X, 1, ENV_SIZE_Y, 1, ENV_SIZE_X, plotMinBound, plotMaxBound, TR); cpgrect(x1, x2, y1, y2); fluxTotal += flux; tGlobal++; flux = 0; //simEnvOdd[50][15] = 100; //simEnvOdd[60][15] = -10; fixBoundaryConditions(simEnvOdd); for (x=1; x<(ENV_SIZE_X-1); x++) for (y=1; y<(ENV_SIZE_Y-1); y++) if ((x+y)%2 == 1) { delta = rateDiff*(simEnvOdd[x][y+1] - 2*simEnvOdd[x][y] + simEnvOdd[x][y-1]); simEnvEven[x][y] += delta; if (INSIDE_BOX) flux += delta; delta = rateDiff*(simEnvOdd[x+1][y] - 2*simEnvOdd[x][y] + simEnvOdd[x-1][y]); simEnvEven[x][y] += delta; if (INSIDE_BOX) flux += delta; } for (x=1; x<(ENV_SIZE_X-1); x++) for (y=1; y<(ENV_SIZE_Y-1); y++) if ((x+y)%2 == 0) { delta = rateDiff*(simEnvEven[x][y+1] - 2*simEnvEven[x][y] + simEnvEven[x][y-1]); simEnvEven[x][y] += delta; if (INSIDE_BOX) flux += delta; delta = rateDiff*(simEnvEven[x+1][y] - 2*simEnvEven[x][y] + simEnvEven[x-1][y]); simEnvEven[x][y] += delta; if (INSIDE_BOX) flux += delta; } loadImage(simEnvEven, plotImg); cpgimag(plotImg, ENV_SIZE_Y, ENV_SIZE_X, 1, ENV_SIZE_Y, 1, ENV_SIZE_X, plotMinBound, plotMaxBound, TR); cpgrect(x1, x2, y1, y2); fluxTotal += flux; tGlobal++; // flux line plot cpgpanl(1,2); cpgsvp(0.08, 0.92, 0.08, 0.92); cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, FLUX_PLOT_Y1, FLUX_PLOT_Y2); cpgmove(tGlobalOld, fluxOld); cpgdraw(tGlobal, flux); // heat line plot totalHeat = 0; for (x=x1; x<=x2; x++) for (y=y1; y<=y2; y++) totalHeat += simEnvEven[x][y]; cpgpanl(1,3); cpgsvp(0.08, 0.92, 0.08, 0.92); cpgswin(LINE_PLOT_X1, LINE_PLOT_X2, LINE_PLOT_Y1, LINE_PLOT_Y2); cpgmove(tGlobalOld, totalHeatOld); cpgdraw(tGlobal, totalHeat); // set trackers tGlobalOld = tGlobal; totalHeatOld = totalHeat; fluxOld = flux; if (tGlobal%100 == 0) { totalHeat = 0; for (x=x1; x<=x2; x++) for (y=y1; y<=y2; y++) totalHeat += simEnvEven[x][y]; fluxAverage = fluxTotal/tGlobal; fluxHeat = totalHeat - totalHeatPre; printf("Total Heat: %f \n Current Divergence: %f \n Current Flux: %f\n\n", totalHeat, flux, fluxHeat); } totalHeatPre = 0; for (x=x1; x<=x2; x++) for (y=y1; y<=y2; y++) totalHeatPre += simEnvEven[x][y]; } }
Image::Image(const char *filename) : buffer(NULL) { loadImage(filename); }
//---------------------------------------------------- bool ofLoadImage(ofPixels & pix, string fileName) { return loadImage(pix,fileName); }
void PlayerShip::init() { shipTexture = Texture( loadImage( loadResource( "ShipMap.png" ) ) ); pg.init(); }
//---------------------------------------------------- bool ofLoadImage(ofFloatPixels & pix, string path){ return loadImage(pix,path); }
/// Main Program int main(int argc, char *argv[]) { CmdLine cmd; std::string combine; ParamDisparity p; // Parameters for adaptive weights cmd.add( make_option('R',p.radius) ); cmd.add( make_option(0,p.gammaCol,"gcol") ); cmd.add( make_option(0,p.gammaPos,"gpos") ); cmd.add( make_option('c', combine) ); try { cmd.process(argc, argv); } catch(std::string str) { std::cerr << "Error: " << str << std::endl<<std::endl; argc = 1; // To display usage } if(argc!=5 && argc!=7) { usage(argv[0]); return 1; } // Load images Image im1 = loadImage(argv[1]); Image im2; if(argc>5) im2 = loadImage(argv[5]); int x,y; if(! ((std::istringstream(argv[2])>>x).eof() && (std::istringstream(argv[3])>>y).eof())) { std::cerr << "Error reading x or y" << std::endl; return 1; } int disp=0; if(argc>6 && !((std::istringstream(argv[6])>>disp).eof()) ) { std::cerr << "Error reading disparity" << std::endl; return 1; } Comb* comb=0; if(cmd.used('c') && im2.channels()!=0) { if(combine == "left") comb = new Comb(left); else if(combine == "max") comb = new Comb(max); else if(combine == "min") comb = new Comb(min); else if(combine == "mult") comb = new Comb(mult); else if(combine == "plus") comb = new Comb(plus); else { std::cerr << "Unrecognized option for weights combination " << "(should be left,max,min,mult or plus)" << std::endl; return 1; } } Image w = show_weights(im1, im2, x, y, x+disp, comb, p.radius, p.gammaCol, p.gammaPos); rescale(w); if(io_png_write_f32(argv[4], &w(0,0), w.width(), w.height(), 1) != 0) { std::cerr << "Unable to write file " << argv[4] << std::endl; return 1; } return 0; }