// Invoke Function bb::cascades::Image PictureHelper::getImage() { // Get random image from list and remove path if (m_imageCount == 0) initListImage(); int rnd = rand() % m_imageCount; // Get imagedata and generate random width & height bb::ImageData img = fromQImage(loadQImage(listImg[rnd])); float ratio = (float)img.width() / (float)img.height(); int max, min; // max min to random width or height max = 700; min = 450; int rnd2 = (rand() % (max - min)) + min; if (ratio > 1) { //if width > height setImageWidth(rnd2); setImageHeight(rnd2 / ratio); } else { // if width < height setImageHeight(rnd2); setImageWidth(rnd2 * ratio); } listImg.removeAt(rnd); setImageCount(listImg.count()); return bb::cascades::Image(img); }
int main(int argc, char *argv[]) { int width, height; width = height = 0; /* read image file */ if (argc >= 2) decode_init(argv[1], &width, &height); /* openGL */ init_gl(argc, argv); createGLBufTex(width, height, GL_BUFFER_SORC); createGLBufTex(width/2, height, GL_BUFFER_DEST); /* openCL */ init_cl(); clloadProgram("./algorithm.cl"); createCLBufferFromGL(); setImageWidth(width); setKernelRange(width/2, height); transferParam(); glutMainLoop(); exit: decode_close(); exit_cl(); exit_gl(); err: return 0; }
/*! * This method creates a new footnote with its properties initially set * from the Attributes/properties of this Layout */ void fl_FrameLayout::_createFrameContainer(void) { lookupProperties(); fp_FrameContainer * pFrameContainer = new fp_FrameContainer(static_cast<fl_SectionLayout *>(this)); setFirstContainer(pFrameContainer); setLastContainer(pFrameContainer); pFrameContainer->setWidth(m_iWidth); pFrameContainer->setHeight(m_iHeight); // Now do Frame image const PP_AttrProp* pSectionAP = NULL; // This is a real NO-NO: must *always* call getAP() // m_pLayout->getDocument()->getAttrProp(m_apIndex, &pSectionAP); getAP(pSectionAP); const gchar * pszDataID = NULL; pSectionAP->getAttribute(PT_STRUX_IMAGE_DATAID, (const gchar *&)pszDataID); DELETEP(m_pGraphicImage); DELETEP(m_pImageImage); // // Set the image size from the full width // setImageWidth(pFrameContainer->getFullWidth()); setImageHeight(pFrameContainer->getFullHeight()); if(pszDataID && *pszDataID) { UT_DEBUGMSG(("!!!Found image of file %s \n",pszDataID)); m_pGraphicImage = FG_Graphic::createFromStrux(this); } setContainerProperties(); }
unsigned char* imageIO::squareImage(unsigned char origImage[], int imageWidth, int imageHeight, int imageBytes) { int newImageWidth = 0; int newImageHeight = 0; if (std::max(imageWidth, imageHeight) == imageWidth) { if (!isPowerOfTwo(imageWidth)) { newImageWidth = pow(2, ceil(log(imageWidth) / log(2))); newImageHeight = newImageWidth; } else { newImageWidth = imageWidth; newImageHeight = imageWidth; } } else { if (!isPowerOfTwo(imageHeight)) { newImageHeight = pow(2, ceil(log(imageHeight) / log(2)));; newImageWidth = newImageHeight; } else { newImageHeight = imageHeight; newImageWidth = imageHeight; } } unsigned char* squareImage = new unsigned char[newImageWidth*newImageHeight*imageBytes]; for (int y = 0; y < newImageHeight; y++) { for (int x = 0; x < newImageWidth; x++) { int oldIndex = ((y * imageWidth * imageBytes) + (x * imageBytes)); int newIndex = ((y * newImageWidth * imageBytes) + (x * imageBytes)); if (x < imageWidth && y < imageHeight) { squareImage[newIndex] = origImage[oldIndex]; squareImage[newIndex + 1] = origImage[oldIndex + 1]; squareImage[newIndex + 2] = origImage[oldIndex + 2]; squareImage[newIndex + 3] = origImage[oldIndex + 3]; } else { squareImage[newIndex] = 255; squareImage[newIndex + 1] = 255; squareImage[newIndex + 2] = 255; squareImage[newIndex + 3] = 255; } } } setImageWidth(newImageWidth); setImageHeight(newImageHeight); return squareImage; }
void UIWidget::parseImageStyle(const OTMLNodePtr& styleNode) { for(const OTMLNodePtr& node : styleNode->children()) { if(node->tag() == "image-source") setImageSource(stdext::resolve_path(node->value(), node->source())); else if(node->tag() == "image-offset-x") setImageOffsetX(node->value<int>()); else if(node->tag() == "image-offset-y") setImageOffsetY(node->value<int>()); else if(node->tag() == "image-offset") setImageOffset(node->value<Point>()); else if(node->tag() == "image-width") setImageWidth(node->value<int>()); else if(node->tag() == "image-height") setImageHeight(node->value<int>()); else if(node->tag() == "image-size") setImageSize(node->value<Size>()); else if(node->tag() == "image-rect") setImageRect(node->value<Rect>()); else if(node->tag() == "image-clip") setImageClip(node->value<Rect>()); else if(node->tag() == "image-fixed-ratio") setImageFixedRatio(node->value<bool>()); else if(node->tag() == "image-repeated") setImageRepeated(node->value<bool>()); else if(node->tag() == "image-smooth") setImageSmooth(node->value<bool>()); else if(node->tag() == "image-color") setImageColor(node->value<Color>()); else if(node->tag() == "image-border-top") setImageBorderTop(node->value<int>()); else if(node->tag() == "image-border-right") setImageBorderRight(node->value<int>()); else if(node->tag() == "image-border-bottom") setImageBorderBottom(node->value<int>()); else if(node->tag() == "image-border-left") setImageBorderLeft(node->value<int>()); else if(node->tag() == "image-border") setImageBorder(node->value<int>()); else if(node->tag() == "image-auto-resize") setImageAutoResize(node->value<bool>()); } }
Fractal::Fractal(QWidget *parent , const char *name , int wFlags) : MainForm(parent,name,wFlags) { Computation c; // put the "What's This" button on the Help menu Help->insertItem( "What's &This", this, SLOT(whatsThis()), SHIFT+Key_F1 ); // puts the "What's This" icon on the toolbar QWhatsThis::whatsThisButton( fileToolBar ); // Find out process rank MPI_Comm_rank (MPI_COMM_WORLD, &my_rank); // Find out number of processes MPI_Comm_size (MPI_COMM_WORLD, &my_size); setImageWidth( DefaultImageWidth ); setImageHeight( DefaultImageHeight ); filename = QString::null; m_filename = QString::null; // get the height of the menu bar and the tool bar menuToolHeight = MenuBar -> height() + fileToolBar -> height(); // get the height of the status bar // statusHeight = statusBar() -> height(); // the following values are the top-left coordnate of the screen where the fractal // is going to be displayed topLeftX = 1; topLeftY = menuToolHeight + 4; // (x,y) is the top - left coordinate of the image to be displayed. x = topLeftX; y = topLeftY; // (sx, sy) specifies the top-left point in pixmap that is to be drawn // (0,0) is the default sx = 0; sy = 0; // (sw, sh) specifies the size of the pixmap that is to be drawn // The default, (-1, -1), means all the way to the bottom right of the pixmap sw = -1; sh = -1; for (int i = 0; i < ColormapSize; ++i) { colormap[i] = c.rgbFromWaveLength(380.0 + (i * 400.0 / ColormapSize)); } // getting the default values for minimum and maximum x and y typeT = data.getType(); // the default fractal, mandelbrot or julia minimumX = data.getMinX(); // Leftmost Real point maximumX = data.getMaxX(); // Rightmost Real point of plane to be displayed minimumY = data.getMinY(); // Lowermost Imaginary point maximumY = data.getMaxY(); // Uppermost Imaginary point resize(data.getWidth() , data.getHeight() + 87 ); // Create a QLabel to display normal & permanent messages status = new QLabel( statusBar() ); status->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); status->setFixedHeight( fontMetrics().height() + 4 ); status->setFixedWidth( width() ); theMessage.sprintf( "Number of nodes = %d " , my_size ); status->setText( theMessage ); saveCount = 0; QString defaultFileName = "Untitled.xml"; QString titleBar = QString( "Phr@X - A Parallel Fractal Explorer - [ %1 ]" ).arg( defaultFileName ); setCaption( titleBar ); } // constructor