Exemplo n.º 1
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updateAspectRatio(); break;
        case 1: settingsChanged(); break;
        case 2: fileCopy3Dto2D(); break;
        case 3: fileNew(); break;
        case 4: fileOpen(); break;
        case 5: fileSave(); break;
        case 6: checkAllRayFeatures(); break;
        case 7: uncheckAllRayFeatures(); break;
        case 8: filterImage(); break;
        case 9: renderImage(); break;
        case 10: activateCanvas2D(); break;
        case 11: activateCanvas3D(); break;
        default: ;
        }
        _id -= 12;
    }
    return _id;
}
Exemplo n.º 2
0
void UINode::renderMiddle (int x, int y) const
{
	if (!_texture)
		return;
	const int childX = x + getRenderX();
	const int childY = y + getRenderY();
	renderImage(_texture, childX, childY, getRenderWidth(), getRenderHeight(), _alpha);
}
Exemplo n.º 3
0
void SDLFrontend::onInit ()
{
	renderBegin();
	ScopedPtr<Texture> ptr(new Texture("loading", this));
	const int x = getWidth() / 2 - ptr->getWidth() / 2;
	const int y = getHeight() / 2 - ptr->getHeight() / 2;
	renderImage(ptr, x, y, ptr->getWidth(), ptr->getHeight(), 0);
	renderEnd();
}
Exemplo n.º 4
0
void Renderer::render()
{
    //renderScene();

    renderText();

	renderImage();

    //renderCubes();
}
Exemplo n.º 5
0
void UiRenderer::render() {
  PROFILER_BLOCK("UiRenderer::render");
  glDepthMask(GL_FALSE);

  renderer.getViewport()->getSize(&viewportWidth, &viewportHeight);

  initCamera();

  // Hand
  renderImage(Vector3f(viewportWidth - 400, 250, -50), Vector3f(960, 540, 1), "hand.png");

  // Crosshair
  renderImage(Vector3f(viewportWidth / 2, viewportHeight / 2, -10), Vector3f(80, 80, 1), "Reticle.png");

  Text glPortalTitle;
  glPortalTitle.font     = "Pacaya";
  glPortalTitle.size     = 1.5f;
  glPortalTitle.content  = "GlPortal";
  glPortalTitle.color    = Vector4f(1, 1, 1, 1);
  glPortalTitle.position = Vector3f(25, viewportHeight - 95, -20);
  renderer.renderText(*renderContext.get(), glPortalTitle);

  Text fpsCounter;
  fpsCounter.font     = "Pacaya";
  fpsCounter.size     = 0.5f;
  fpsCounter.content  = std::string("FPS: ") + std::to_string(Game::fps.getFps());
  fpsCounter.color    = Vector4f(1, 1, 1, 1);
  fpsCounter.position = Vector3f(10, viewportHeight - 25, -20);
  renderer.renderText(*renderContext.get(), fpsCounter);

  Text version;
  version.font     = "Pacaya";
  version.size     = 0.5f;
  version.content  = std::string("Early testing build: ")  + GAME_VERSION;
  version.color    = Vector4f(1, 1, 1, 1);
  version.position = Vector3f(10, viewportHeight - 45, -20);
  renderer.renderText(*renderContext.get(), version);

  renderContext->popCamera();

  glDepthMask(GL_TRUE);
}
Exemplo n.º 6
0
/**
 * Draw this object from this point of view, and return
 * the resulting image.  
 * The output CkView will be unref()'d exactly once after
 * each call to render.
 */
CkView *CkInterestViewable::renderView(const CkViewpoint &univ2screen) {
	CkViewpoint univ2texture;
	priorityAdjust=0; /* no priority */
	if (!newViewpoint(univ2screen,univ2texture))
		return NULL;
	CkInterestView *ret=new CkInterestView(
		univ2texture.getWidth(),univ2texture.getHeight(),4,
		interest,univ2texture);
	renderImage(univ2texture,ret->getImage());
	return ret;
}
Exemplo n.º 7
0
RasterLabel::RasterLabel(QWidget *parent):QLabel(parent)
{

    tmr = new QTimer(parent);
    connect(tmr,SIGNAL(timeout()),this, SLOT(renderImage()));
    connect(this,SIGNAL(nothingToDisplay()), this, SLOT(noDisplayableImage()));
    setMouseTracking(true);
    setImageFromWebcam(false);
    filter = NULL;
    tmr->start(50);
}
Exemplo n.º 8
0
// Render the openGL scene
void CVOpenGLWidget::paintGL()
{
    if( !sceneChanged_ )
        return;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    renderImage();

    sceneChanged_ = false;
}
Exemplo n.º 9
0
void OpenCVViewer::paintGL()
{
    makeCurrent();

    if(!isSceneChanged)
        return;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    renderImage();

    isSceneChanged = false;
}
Exemplo n.º 10
0
void TileBoundsCalculator::renderImage(shared_ptr<OsmMap> map)
{
  _envelope = map->calculateBounds();

  renderImage(map, _r1, _r2);

  _calculateMin();

  _exportImage(_r1, "tmp/r1.png");
  _exportImage(_r2, "tmp/r2.png");
  _exportImage(_min, "tmp/min.png");
}
int UINodeBackgroundScene::renderGround (int x, int y) const
{
	const TextureVector& tiles = ThemeTypes::isIce(*_theme) ? _groundsIce : _groundsRock;
	const int groundCnt = tiles.size();
	const int renderHeight = getRenderHeight(false);
	const int groundY = y + renderHeight - _imageHeight / 4;
	for (int col = 0; col <= _amountHorizontal; ++col) {
		const TexturePtr& t = tiles[col % groundCnt];
		renderImage(t, x + _imageWidth * col, groundY);
	}
	return groundY;
}
Exemplo n.º 12
0
GLRectDrawable::GLRectDrawable(QObject *parent)
    : GLImageDrawable("",parent)
    , m_fillColor(Qt::white)
    , m_borderColor(Qt::black)
    , m_borderWidth(3.0)
    , m_cornerRounding(0)
{
    // Dont lock scaling to aspect ratio
    setFreeScaling(true);

    renderImage();
}
Exemplo n.º 13
0
void QtOpenCVViewerGl::paintGL()
{
    makeCurrent();

    glClearColor(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT);

    if(mSceneChanged)
        renderImage();

    mSceneChanged = false;
}
void UINodeBackgroundScene::renderBackground (int x, int y) const
{
	const TextureVector& tiles = ThemeTypes::isIce(*_theme) ? _tilesIce : _tilesRock;
	const int tileCnt = tiles.size();
	const int renderHeight = getRenderHeight(false);
	for (int row = 0; row <= _amountVertical; ++row) {
		const int renderY = y + renderHeight - (row * _imageHeight + _imageHeight / 4);
		for (int col = 0; col <= _amountHorizontal; ++col) {
			const TexturePtr& t = tiles[((row * _amountHorizontal) + col) % tileCnt];
			renderImage(t, x + _imageWidth * col, renderY);
		}
	}
}
void UINodeBackgroundScene::renderFailedCenter (int x, int y, const MapFailedReason& reason) const
{
	FailedMap::const_iterator i = _failed.find(&reason);
	if (i == _failed.end())
		return;
	const TexturePtr& t = i->second;
	if (!t || !t->isValid())
		return;

	const int playerX = x + getRenderCenterX() - t->getWidth() / 2;
	const int playerY = y + getRenderCenterY() - t->getHeight() / 2;
	renderImage(t, playerX, playerY);
}
Exemplo n.º 16
0
QImage QwtPlotRasterItem::compose( 
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &imageArea, const QRectF &paintRect, 
    const QSize &imageSize, bool doCache) const
{
    QImage image;
    if ( imageArea.isEmpty() || paintRect.isEmpty() || imageSize.isEmpty() )
        return image;

    if ( doCache )
    {
        if ( !d_data->cache.image.isNull()
            && d_data->cache.area == imageArea
            && d_data->cache.size == paintRect.size() )
        {
            image = d_data->cache.image;
        }
    }

    if ( image.isNull() )
    {
        double dx = 0.0;
        if ( paintRect.toRect().width() > imageSize.width() )
            dx = imageArea.width() / imageSize.width();

        const QwtScaleMap xxMap = 
            imageMap(Qt::Horizontal, xMap, imageArea, imageSize, dx);
        
        double dy = 0.0;
        if ( paintRect.toRect().height() > imageSize.height() )
            dy = imageArea.height() / imageSize.height();

        const QwtScaleMap yyMap = 
            imageMap(Qt::Vertical, yMap, imageArea, imageSize, dy);

        image = renderImage( xxMap, yyMap, imageArea, imageSize );

        if ( doCache )
        {
            d_data->cache.area = imageArea;
            d_data->cache.size = paintRect.size();
            d_data->cache.image = image;
        }
    }

    if ( d_data->alpha >= 0 && d_data->alpha < 255 )
        image = toRgba( image, d_data->alpha );

    return image;
}
Exemplo n.º 17
0
int main()
{
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        std::cout << SDL_GetError() << "-----init----" <<std::endl;
        return -1;
    }
    if ((IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) != IMG_INIT_PNG) {
        std::cout << "IMG_INIT_ERROR" << std::endl;
    }
    win = SDL_CreateWindow("PNG_TEST1", 100, 100, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
    ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    //code
    renderImage("back.png", 0, 0);
    renderImage("front.png", 100, 100);
    
    SDL_Delay(2000);
    SDL_DestroyRenderer(ren);
    SDL_DestroyWindow(win);

    SDL_Quit();
    IMG_Quit();
    return 0;
}
void UINodeBackgroundScene::renderFailedOnGround (int x, int y, const MapFailedReason& reason, float offsetY) const
{
	renderCave(x, y);
	const int groundY = renderGround(x, y);
	FailedMap::const_iterator i = _failed.find(&reason);
	if (i == _failed.end())
		return;
	const TexturePtr& t = i->second;
	if (!t || !t->isValid())
		return;

	const int playerX = x + getRenderCenterX() - t->getWidth() / 2;
	const int playerY = groundY - t->getHeight() + offsetY * t->getHeight();
	renderImage(t, playerX, playerY);
}
Exemplo n.º 19
0
void ParticleField::Render() {
  glEnable(GL_TEXTURE_2D);
  m_ParticleTexture->bind();
  static ci::Color c = ci::Color(0.4f, 0.7f, 0.9f);
  static ci::Color c2 = ci::Color(0.9f, 0.6f, 0.1f);
  glPushMatrix();
  for (std::list<Particle>::iterator it = m_Particles.begin(); it != m_Particles.end(); it++) {
    const ci::Vec4f back = it->history.back();
    float temp = static_cast<float>((it->radius-MIN_RADIUS)/(MAX_RADIUS-MIN_RADIUS));
    ci::Color curColor = c*temp + c2*(1-temp);
    float radius = it->radius * back[3];
    ci::Vec3f pos(back[0], back[1], back[2]);
    scaleVec3(pos);
    glEnable(GL_TEXTURE_2D);
    renderImage(pos, radius, curColor, back[3]);
    glDisable(GL_TEXTURE_2D);
    glBegin(GL_QUAD_STRIP);
    float total = static_cast<float>(it->history.size());
    for (int i = static_cast<int>(it->history.size())-1; i>0; i--) {
      float per = static_cast<float>(i) / total;
      const ci::Vec4f& cur = it->history[i];
      const ci::Vec4f& last = it->history[i-1];
      ci::Vec3f curPos(cur[0], cur[1], cur[2]);
      ci::Vec3f lastPos(last[0], last[1], last[2]);
      scaleVec3(curPos);
      scaleVec3(lastPos);

      ci::Vec3f perp0 = curPos - lastPos;
      ci::Vec3f perp1 = perp0.cross(ci::Vec3f::zAxis());
      ci::Vec3f perp2 = perp0.cross(perp1);
      perp1 = perp0.cross(perp2).normalized();
      float offWidth = (it->radius * cur[3] * per * 0.07f);
      float opacityScale = 0.95f*back[3]*per;
      if (per > 0.8f) {
        float temp = (1.0f - per) / 0.2f;
        float tempScale = sqrt(temp);
        offWidth *= tempScale;
        opacityScale *= tempScale;
      }
      ci::Vec3f off = perp1 * offWidth;
      glColor4f(curColor.r, curColor.g, curColor.b, opacityScale);
      ci::gl::vertex(curPos - off);
      ci::gl::vertex(curPos + off);
    }
    glEnd();
  }
  glPopMatrix();
}
Exemplo n.º 20
0
void RenderQueue::renderImage()
{
    KImageData *imageData = qobject_cast<KImageData*>(m_pictureShape->userData());
    if (m_wantedImageSize.isEmpty() || imageData == 0) {
        return;
    }
    QSize size = m_wantedImageSize.takeFirst();
    QString key(generate_key(imageData->key(), size));
    if (QPixmapCache::find(key) == 0) {
        QPixmap pixmap = imageData->pixmap(size);
        QPixmapCache::insert(key, pixmap);
        m_pictureShape->update();
    }
    if (! m_wantedImageSize.isEmpty()) {
        QTimer::singleShot(0, this, SLOT(renderImage()));
    }
}
QImage QuickWindowNodeInstance::renderImage() const
{
    /*
     Since the content item transucient
     we just fill an image with the window color
     */

    QRectF renderBoundingRect = boundingRect();

    QImage renderImage(renderBoundingRect.size().toSize(), QImage::Format_ARGB32_Premultiplied);

    QPalette palette;

    renderImage.fill(palette.color(QPalette::Window).rgba());

    return renderImage;
}
Exemplo n.º 22
0
/*!
  Draw the spectrogram

  \param painter Painter
  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  \param radialMap Maps radius values into painter coordinates.
  \param pole Position of the pole in painter coordinates
  \param radius Radius of the complete plot area in painter coordinates
  \param canvasRect Contents rect of the canvas in painter coordinates
*/
void QwtPolarSpectrogram::draw( QPainter *painter,
    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
    const QPointF &pole, double,
    const QRectF &canvasRect ) const
{
    const QRectF plotRect = plot()->plotRect( canvasRect.toRect() );

    QRegion clipRegion( canvasRect.toRect() );
    if ( qwtNeedsClipping( plotRect, canvasRect ) )
    {
        // For large plotRects the ellipse becomes a huge polygon.
        // So we better clip only, when we really need to.

        clipRegion &= QRegion( plotRect.toRect(), QRegion::Ellipse );
    }

    QRect imageRect = canvasRect.toRect();

    if ( painter->hasClipping() )
        imageRect &= painter->clipRegion().boundingRect();

    const QwtInterval radialInterval =
        boundingInterval( QwtPolar::ScaleRadius );
    if ( radialInterval.isValid() )
    {
        const double radius = radialMap.transform( radialInterval.maxValue() ) -
                              radialMap.transform( radialInterval.minValue() );

        QRectF r( 0, 0, 2 * radius, 2 * radius );
        r.moveCenter( pole );

        clipRegion &= QRegion( r.toRect(), QRegion::Ellipse );;

        imageRect &= r.toRect();
    }

    const QImage image = renderImage( azimuthMap, radialMap, pole, imageRect );

    painter->save();
    painter->setClipRegion( clipRegion );

    painter->drawImage( imageRect, image );

    painter->restore();
}
Exemplo n.º 23
0
void UINodeMapSelector::renderSelectorEntry (int index, const std::string& data, int x, int y, int colWidth,
		int rowHeight, float alpha) const
{
	const TexturePtr t = getIcon(data);
	if (t)
		renderImage(t, x, y, colWidth, rowHeight, alpha);

	if (_campaignManager != nullptr) {
		const CampaignPtr& campaignPtr = _campaignManager->getActiveCampaign();
		const CampaignMap *map = campaignPtr->getMapById(data);
		if (map != nullptr && !map->isLocked()) {
			const BitmapFontPtr& font = getFont(MEDIUM_FONT);
			const std::string points = string::toString(map->getFinishPoints());
			const int fontX = x + colWidth / 2 - font->getTextWidth(points) / 2;
			const int fontY = y + font->getTextHeight(points);
			font->print(points, colorWhite, fontX, fontY);
		}
	}

	if (_selectedIndex != index)
		return;

	std::string title;
	if (_mapManager != nullptr) {
		title = _mapManager->getMapTitle(data);
	} else {
		const CampaignPtr& campaignPtr = _campaignManager->getActiveCampaign();
		const CampaignMap *map = campaignPtr->getMapById(data);
		if (map == nullptr)
			return;
		title = map->getName();
	}

	if (!title.empty()) {
		const BitmapFontPtr& font = getFont(SMALL_FONT);
		const int textHeight = font->getTextHeight(title);
		const int fontX = x + colWidth / 2 - font->getTextWidth(title) / 2;
		const int fontY = y + rowHeight - textHeight - 1;
		_frontend->renderFilledRect(x, fontY - 1, colWidth, textHeight + 2, highlightColor);
		_frontend->renderRect(x, fontY - 1, colWidth, textHeight + 2, colorWhite);
		font->print(title, colorWhite, fontX, fontY);
	}
}
Exemplo n.º 24
0
void *ThreadCode(void *argument)
{
	uint32_t tid;
	tid = *((int *) argument);
	printf("Thread %i gestartet\n", tid);
	
	if (fileMode) {
		//file oeffnen
		char buf[255];
		snprintf(buf, 255, "%d.xyrgb", tid);
		files[tid] = fopen(buf,"wb");
	}	
	
	renderImage(&(tiles[tid]),tid);
	
	//file schliessen
	if (fileMode) {
		fclose(files[tid]);
	}
	return NULL;
}
void GLWidget3D::gaborFilterTest() {
	glUniform1i(glGetUniformLocation(renderManager.program, "depthComputation"), 0);

	loadObject("psb_test/m0.off");

	int pitch_angle_step = 180;
	int yaw_angle_step = 360;

	camera.xrot = 0;
	camera.yrot = 0;
	camera.zrot = 0.0f;
	camera.pos.z = 1.6f;

	camera.updateMVPMatrix();

	cv::Mat image;
	renderImage(image);
	image = 255 - image;

	BagOfFeature bof(image, "psb_test/m0.off", camera, 4.0f, 10.0f, width() * 0.2f, height() * 0.2f);
}
Exemplo n.º 26
0
/** \brief Updates the MapViewer.
 *          It gives an suitable output based on the users input, writes an title into the screen
 *          and executed the map render method.
 *          It also displays an description of the current map field, the player is standing on.
 *
 * \param input std::string The users input.
 * \return void
 *
 */
void MapViewer::update(std::string input)
{
	if(_subMap != NULL)
	{
		_subMap->update(input);
		return;
	}
	executeInput(input);

	_gameManager->print("╓────────────────────────────────────╖\n");
	_gameManager->print("║ THE HOLY KINGDOM \033[4m\033[1mMODGNI KYLOH EHT\033[0m: ║\n");
	_gameManager->print("╙────────────────────────────────────╜\n");
	renderImage();
	_gameManager->printText("You are " + getFieldDescription(_selectedFieldChar));
	    std::cout << std::regex_match(_selectedFieldChar + "", std::regex("1|2|3")) << " - " << _selectedFieldChar << std::endl;
	if(_enterErrorMessage == "")
	{
        if(std::regex_match(std::string(1, _selectedFieldChar), std::regex("[1-3]"))) _gameManager->printText("You can E N T E R this area.\n");
        else _gameManager->printText("You can NOT(!) E N T E R this area (yet).\n");
	}
	else _gameManager->printText(_enterErrorMessage);
}
Exemplo n.º 27
0
//--------------------------------------------------------------
void ofApp::draw(){
	
	ofBackground(0, 0, 0);
	ofFill();
	
	if(true)
	{
		if( myScreen.isReceivingPixels() ){
			renderPixelsReceive();
		}else if(gui.getValueI("CONTENT_TYPE")==0){
			renderVideo();
		}else if(gui.getValueI("CONTENT_TYPE")==1){
			renderImage();
		}
	}
	
	if(activeGUI)
	{
		ofShowCursor();
		gui.draw();
    }else{
        ofHideCursor();
    }
}
// this function passed the jpeg image buffer in, and returns the decoded
// image
int
decodeImage(OPENMAX_JPEG_DECODER * decoder, char *sourceImage,
	    size_t imageSize)
{
    char           *sourceOffset = sourceImage;	// we store a seperate
						// buffer ot image so we
						// can offset it
    size_t          toread = 0;	// bytes left to read from buffer
    toread += imageSize;
    int             bFilled = 0;	// have we filled our output
					// buffer
    bufferIndex = 0;

    while (toread > 0) {
	// get next buffer from array
	OMX_BUFFERHEADERTYPE *pBufHeader =
	    decoder->ppInputBufferHeader[bufferIndex];

	// step index and reset to 0 if required
	bufferIndex++;
	if (bufferIndex >= decoder->inputBufferHeaderCount)
	    bufferIndex = 0;

	// work out the next chunk to load into the decoder
	if (toread > pBufHeader->nAllocLen)
	    pBufHeader->nFilledLen = pBufHeader->nAllocLen;
	else
	    pBufHeader->nFilledLen = toread;

	toread = toread - pBufHeader->nFilledLen;

	// pass the bytes to the buffer
	memcpy(pBufHeader->pBuffer, sourceOffset, pBufHeader->nFilledLen);
	printf("Read into buffer %d\n", pBufHeader->nFilledLen);

	// update the buffer pointer and set the input flags

	sourceOffset = sourceOffset + pBufHeader->nFilledLen;
	pBufHeader->nOffset = 0;
	pBufHeader->nFlags = 0;
	if (toread <= 0) {
	    pBufHeader->nFlags = OMX_BUFFERFLAG_EOS;
	    printf("Added EOS to last inout buffer\n");
	}
	// empty the current buffer
	printf("Emptying buffer\n");
	int             ret =
	    OMX_EmptyThisBuffer(decoder->imageDecoder->handle,
				pBufHeader);

	if (ret != OMX_ErrorNone) {
	    perror("Empty input buffer");
	    fprintf(stderr, "return code %x\n", ret);
	    return OMXJPEG_ERROR_MEMORY;
	}
	// wait for buffer to empty or port changed event
	int             done = 0;
	while ((done == 0) || (decoder->pOutputBufferHeader == NULL)) {
	    if (decoder->pOutputBufferHeader == NULL) {
		ret =
		    ilclient_wait_for_event
		    (decoder->imageDecoder->component,
		     OMX_EventPortSettingsChanged,
		     decoder->imageDecoder->outPort, 0, 0, 1, 0, 5);

		if (ret == 0) {
		    portSettingsChanged(decoder);
		}
	    } else {
		ret =
		    ilclient_remove_event(decoder->imageDecoder->component,
					  OMX_EventPortSettingsChanged,
					  decoder->imageDecoder->outPort,
					  0, 0, 1);
		if (ret == 0)
		    portSettingsChangedAgain(decoder);

	    }

	    // check to see if buffer is now empty
	    if (pBufHeader->nFilledLen == 0)
		done = 1;

	    if ((done == 0)
		|| (decoder->pOutputBufferHeader == NULL)) {
		printf("Buffer is now size %d\n", pBufHeader->nFilledLen);
		sleep(1);
	    }
	}

	// fill the buffer if we have created the buffer
	if (bFilled == 0) {
	    if ((decoder->pOutputBufferHeader == NULL)) {
		portSettingsChanged(decoder);
	    }
	    OMX_PARAM_U32TYPE param;
	    param.nSize = sizeof(OMX_PARAM_U32TYPE);
	    param.nVersion.nVersion = OMX_VERSION;
	    param.nPortIndex = decoder->imageDecoder->outPort;
	   
	    OMX_GetParameter(decoder->imageDecoder->handle,
		     OMX_IndexParamActiveStream, &param);
	    printf("Active stream %d\n", param.nU32);

	    printf("Trying to fill output buffer\n");
	    printState(decoder->imageDecoder->handle);
	    ret = OMX_FillThisBuffer(decoder->imageDecoder->handle,
				     decoder->pOutputBufferHeader);
	    
	    if (ret != OMX_ErrorNone) {
		perror("Filling output buffer");
		fprintf(stderr, "Error code %x\n", ret);
		return OMXJPEG_ERROR_MEMORY;
	    }

	    bFilled = 1;
	}
    }

    // wait for buffer to fill
    /*
     * while(pBufHeader->nFilledLen == 0) { sleep(5); } 
     */

    // wait for end of stream events
    int             ret =
	ilclient_wait_for_event(decoder->imageDecoder->component,
				OMX_EventBufferFlag,
				decoder->imageDecoder->outPort, 1,
				OMX_BUFFERFLAG_EOS, 1,
				0, 2);
    if (ret != 0) {
	fprintf(stderr, "No EOS event on image decoder %d\n", ret);
    } else  {
	fprintf(stderr, "EOS event on image decoder %d\n", ret);
    }

    printf("Resized %d\n", decoder->pOutputBufferHeader->nFilledLen);
    FILE *fp = fopen("out", "w");
    int n;
    for (n = 0; n < decoder->pOutputBufferHeader->nFilledLen; n++) {
	//fputc(decoder->pOutputBufferHeader->pBuffer[n], fp);
	fputc(decoder->ppRenderInputBufferHeader[0]->pBuffer[n], fp);
    }
    fclose(fp);
    printf("File written\n");

    renderImage(decoder);

    return OMXJPEG_OK;
}
Exemplo n.º 29
0
void QgsHeatmapRenderer::stopRender( QgsRenderContext& context )
{
  renderImage( context );
  mWeightExpression.reset();
}
Exemplo n.º 30
0
bool QgsHeatmapRenderer::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
{
  Q_UNUSED( layer );
  Q_UNUSED( selected );
  Q_UNUSED( drawVertexMarker );

  if ( !context.painter() )
  {
    return false;
  }

  if ( !feature.constGeometry() || feature.constGeometry()->type() != QGis::Point )
  {
    //can only render point type
    return false;
  }

  double weight = 1.0;
  if ( !mWeightExpressionString.isEmpty() )
  {
    QVariant value;
    if ( mWeightAttrNum == -1 )
    {
      Q_ASSERT( mWeightExpression.data() );
      value = mWeightExpression->evaluate( &feature );
    }
    else
    {
      QgsAttributes attrs = feature.attributes();
      value = attrs.value( mWeightAttrNum );
    }
    bool ok = false;
    double evalWeight = value.toDouble( &ok );
    if ( ok )
    {
      weight = evalWeight;
    }
  }

  int width = context.painter()->device()->width() / mRenderQuality;
  int height = context.painter()->device()->height() / mRenderQuality;

  //transform geometry if required
  QgsGeometry* transformedGeom = 0;
  const QgsCoordinateTransform* xform = context.coordinateTransform();
  if ( xform )
  {
    transformedGeom = new QgsGeometry( *feature.constGeometry() );
    transformedGeom->transform( *xform );
  }

  //convert point to multipoint
  QgsMultiPoint multiPoint = convertToMultipoint( transformedGeom ? transformedGeom : feature.constGeometry() );

  delete transformedGeom;
  transformedGeom = 0;

  //loop through all points in multipoint
  for ( QgsMultiPoint::const_iterator pointIt = multiPoint.constBegin(); pointIt != multiPoint.constEnd(); ++pointIt )
  {
    QgsPoint pixel = context.mapToPixel().transform( *pointIt );
    int pointX = pixel.x() / mRenderQuality;
    int pointY = pixel.y() / mRenderQuality;
    for ( int x = qMax( pointX - mRadiusPixels, 0 ); x < qMin( pointX + mRadiusPixels, width ); ++x )
    {
      for ( int y = qMax( pointY - mRadiusPixels, 0 ); y < qMin( pointY + mRadiusPixels, height ); ++y )
      {
        int index = y * width + x;
        if ( index >= mValues.count( ) )
        {
          continue;
        }
        double distanceSquared = pow( pointX - x, 2.0 ) + pow( pointY - y, 2.0 );
        if ( distanceSquared > mRadiusSquared )
        {
          continue;
        }

        double score = weight * quarticKernel( sqrt( distanceSquared ), mRadiusPixels );
        double value = mValues[ index ] + score;
        if ( value > mCalculatedMaxValue )
        {
          mCalculatedMaxValue = value;
        }
        mValues[ index ] = value;
      }
    }
  }

  mFeaturesRendered++;
#if 0
  //TODO - enable progressive rendering
  if ( mFeaturesRendered % 200  == 0 )
  {
    renderImage( context );
  }
#endif
  return true;
}