示例#1
0
bool TextureAtlas::addImage(const ImageHandle& newImageHandle) 
{
    if(imageSubTextures.Find( newImageHandle ) != imageSubTextures.End())
        return true;

    Image* newImage = newImageHandle.Resolve();

    Rectangle newRect = rectanglePacker.Insert(newImage->getWidth()+1, newImage->getHeight()+1, gs_heuristic);

    if (newRect.height == 0 || newRect.width == 0){
        if (atlasSize >= atlasMaxSize)
            return false;

        atlasSize = std::min(atlasSize*2, atlasMaxSize);
        resizeAtlas(atlasSize);

        return addImage(newImageHandle);
    }

    newRect.width--;
    newRect.height--;

    addImage(newImageHandle,newRect);

    return true;
}
示例#2
0
void promptSDcard(struct Env* p, alt_up_sd_card_dev* device_reference) {
	/*
	 * Loading Screen if SD card is not presented
	 */

	int frame = 25;
	struct animation* b = initAnimation((int*)pacman01, 1);
	addImage(b, initAnimation((int*)pacman02, 0));
	addImage(b, initAnimation((int*)pacman03, 0));
	addImage(b, initAnimation((int*)pacman04, 0));
	struct Object *face;
	face= initObject(80, 120, 10, b, NULL);
	addToEnv(p, face);

	alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p);


	while(!loadSDCard(device_reference)) {
		displayString("Please insert the SD card to start", frame, 30);
		frame++;
		setXY(face, face->x+4, face->y);
		if(face->x >245) face->x = 0;
		if(frame > 61) frame = 0;

		usleep(300000);
	}alt_up_char_buffer_clear(char_buffer);
	killAnimation(b);
	removeFromEnv(p, face);
	alt_alarm_stop(&alarm);
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
}
示例#3
0
Image::Image(const QString &str, int idx, ImageCollection *w)
: GfxCanvasMipImage(MAXIMIZED_SIZE, w), _listItem(0), _color(Qt::white, MAXIMIZED_SIZE, this), _idx(idx), _loaded(false), _str(str), _collection(w), _imageParent(this)
{
    _color.visible().setValue(0.);
    if(_defMaximized.isNull()) {

        _defMaximized = QImage(MAXIMIZED_SIZE, QImage::Format_RGB16);
        _defMaximized.fill(0xFFFFFFFF);
        QPainter p(&_defMaximized);
        p.fillRect(BORDER_THICKNESS, BORDER_THICKNESS, MAXIMIZED_SIZE.width() - 2 * BORDER_THICKNESS, MAXIMIZED_SIZE.height() - 2 * BORDER_THICKNESS, Qt::black);
        p.setPen(Qt::white);
        p.setBrush(Qt::white);
        QFont f;
        f.setPixelSize(MAXIMIZED_SIZE.height());
        p.setFont(f);
        p.drawText(_defMaximized.rect(), Qt::AlignVCenter | Qt::AlignCenter, "?");

        _defSmall = _defMaximized.scaled(SMALL_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).convertToFormat(QImage::Format_RGB16);
        _defZoomed = _defMaximized.scaled(ZOOMED_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).convertToFormat(QImage::Format_RGB16);
        _defTimeView = _defMaximized.scaled(TIMEVIEW_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).convertToFormat(QImage::Format_RGB16);
 
    }

    _def.setValue(1.);
    addImage(_defMaximized);
    addImage(_defTimeView);
    addImage(_defSmall);
    addImage(_defZoomed);
}
示例#4
0
void Image::paint(GfxPainter &p)
{

    if(!_collection->isOnScreen(_idx))
        return;

    if(!_loaded) {
        loadImage(_str, QList<QSize>() << QSize(320, 240));
        _loaded = true;
    }

    if(_def.value() == 2. && !_maximized.isNull()) {
        clear();
        addImage(_maximized);
        addImage(_small);
        addImage(_zoomed);
        addImage(_timeView);
        _maximized = _small = _zoomed = _timeView = QImage();
    }

    _color.rotate().setValue(rotate().value());
    _color.quality().setValue(quality().value());

    GfxCanvasMipImage::paint(p);
}
示例#5
0
文件: img_button.cpp 项目: z80/avrusb
void CImgButton::setPictures( const QString & unchecked, const QString & checked )
{
    m_picsSz.clear();
    addImage( unchecked );
    m_uName = unchecked;
    addImage( checked );
    m_cName = checked;
}
示例#6
0
文件: img_button.cpp 项目: z80/avrusb
void CImgButton::setPicturesHovered( const QString & unchecked, const QString & checked )
{
    m_picsSz.clear();
    addImage( unchecked );
    m_uhName = unchecked;
    addImage( checked );
    m_chName = checked;
    m_hovered = true;
}
DisplaceMapShader::DisplaceMapShader(ofImage * p_colormap, ofImage * p_displacemap, float p_maxHeight)
: MappingShader(DISPLACEMENT) {
    if (p_colormap != NULL) {
        addImage(p_colormap);
    }
    if (p_displacemap != NULL) {
        addImage(p_displacemap);
    }
    m_maxHeight = p_maxHeight;
}
示例#8
0
// ---------------------------------------------------------------------------------------
void HtmlReport::addTableImage(std::string file, std::string caption, std::string href)
{
    if (!isTable_) beginTable();
    if (!isTableRow_) beginTableRow();
    out_ << "<td>";
    if (href.size() == 0)
	addImage(file, caption);
    else
	addImage(file, caption, href);
    out_ << "<br/>" << caption << "</td>" << endl;
}
示例#9
0
void AManager::setMenuRessource()
{
  addImage("../ressources/images/MainBG.jpg", "MainBG");
  addImage("../ressources/images/bg.jpg", "bg");
  addImage("../ressources/images/r_type-logo.png", "rtype_logo");
  addImage("../ressources/images/highlight.png", "highlight");
  addImage("../ressources/images/earth.png", "earth");
  addFont("../ressources/fonts/font.ttf", "default");
  addFont("../ressources/fonts/spaceage.ttf", "spaceage");
  addFont("../ressources/fonts/Android.ttf", "Android");
}
////////////////////////////////////////////////////////
//
// TextureTest
//
////////////////////////////////////////////////////////
void TextureTest::performTestsPNG(const char* filename)
{
    struct timeval now;
    Texture2D *texture;
    auto cache = Director::getInstance()->getTextureCache();
    
    Texture2D::PixelFormat defaultFormat = Texture2D::getDefaultAlphaPixelFormat();

    log("RGBA 8888");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888);
    gettimeofday(&now, NULL);
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);

    log("RGBA 4444");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444);
    gettimeofday(&now, NULL);
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);

    log("RGBA 5551");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1);
    gettimeofday(&now, NULL);
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);

    log("RGB 565");
    Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565);
    gettimeofday(&now, NULL);    
    texture = cache->addImage(filename);
    if( texture )
        log("  ms:%f", calculateDeltaTime(&now) );
    else
        log(" ERROR");
    cache->removeTexture(texture);
    
    Texture2D::setDefaultAlphaPixelFormat(defaultFormat);
}
示例#11
0
MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    webView = new QWebView();
    webView->setWindowTitle("contentEditor preview");
    webView->setWindowFlags(Qt::WindowStaysOnTopHint); // | Qt::FramelessWindowHint

    pageHandler::loadPages();
    pageHandler::treeWidget = ui->pagesList;
    pageHandler::pageStack = ui->pageStack;
    pageHandler::webView = webView;
    pageHandler::setup();

    setGeometry(50, 50, 1200, 700);

    connect(ui->savePage,SIGNAL(triggered()),pageHandler::getSingleton(), SLOT(savePage()));
    connect(ui->togglePagesList,SIGNAL(triggered()),this, SLOT(togglePagesList()));
    connect(ui->toggleFullscreen,SIGNAL(triggered()),this, SLOT(toggleFullscreen()));
    connect(ui->togglePreview,SIGNAL(triggered()),this, SLOT(togglePreview()));
    connect(ui->newPage,SIGNAL(triggered()),this, SLOT(addPage()));
    connect(ui->newField,SIGNAL(triggered()),this, SLOT(addField()));
    connect(ui->backgroundColor, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(setFieldBackgroundColor()));
    connect(ui->addImage, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(addImage()));
    connect(ui->toggleText, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(toggleTextEdit()));
    connect(ui->pageBackgroundColor, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(setPageBackgroundColor()));
    connect(ui->printPDF, SIGNAL(triggered()), pageHandler::getSingleton(), SLOT(exportPDF()));


    lastWebViewGeometry = QRect(200,200,500,400);
}
示例#12
0
void NewGameTab::addImages(const QStringList& images)
{
	int count = images.count();
	if (count == 0) {
		return;
	}

	QProgressDialog progress(tr("Copying images..."), tr("Cancel"), 0, count, this);
	progress.setMinimumDuration(500);
	progress.setWindowModality(Qt::WindowModal);

	QApplication::setOverrideCursor(Qt::WaitCursor);

	m_image_tags->clearFilter();
	for (int i = 0; i < count; i++) {
		progress.setValue(i);
		if (progress.wasCanceled()) {
			break;
		}

		addImage(images.at(i));

		QApplication::processEvents();
	}
	progress.setValue(count);

	QApplication::restoreOverrideCursor();
}
示例#13
0
Animation* GameUtils::getAnimationByKeyAndFileName(const std::string& aniKey, const std::string& fileName,
                                                   
                                                   
                                                   const int& frameCount, float delay){
    auto animCache = AnimationCache::getInstance();
    auto resultAnimation = animCache->getAnimation(aniKey);
    if( resultAnimation == nullptr){
        auto cache = Director::getInstance()->getTextureCache();
        Vector<SpriteFrame*> animFrames(frameCount);
        char str[50] = {0};
        for(int i = 0; i < frameCount; i++){
            sprintf(str, fileName.c_str(),i);
            auto texture = cache->addImage(str);
            CCASSERT(texture != nullptr, "texture is null!");
            auto size = texture->getContentSize();
            auto rect = Rect(0, 0, size.width, size.height);
            auto frame = SpriteFrame::createWithTexture(texture, rect);
            animFrames.pushBack(frame);
        }
        auto animation = Animation::createWithSpriteFrames(animFrames, delay);
        
        // Add an animation to the Cache
        AnimationCache::getInstance()->addAnimation(animation, aniKey);
        animFrames.clear();
        resultAnimation = animCache->getAnimation(aniKey);
        //log("no cache");
    }
    return resultAnimation;
}
示例#14
0
Water *Water::create(const std::string& fileName, const std::string& waveFileOne, const std::string& waveFileTwo, const cocos2d::Size& size, float hSpeed, float vSpeed, float saturation)
{
	Water *water = new (std::nothrow) Water();
	if (water && water->initWithFile(fileName, cocos2d::Rect(0, 0, size.width, size.height)))
	{
		water->autorelease();

		auto TexCache = cocos2d::Director::getInstance()->getTextureCache();
		auto wave2 = TexCache->addImage(waveFileOne);
		auto wave1 = TexCache->addImage(waveFileTwo);

		cocos2d::Texture2D::TexParams wave1TexParams = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT };
		cocos2d::Texture2D::TexParams wave2TexParams = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT };
		wave1->setTexParameters(wave1TexParams);
		wave2->setTexParameters(wave2TexParams);
		auto glprogram = cocos2d::GLProgram::createWithFilenames("shader3D/water.vsh", "shader3D/water.fsh");
		auto glprogramstate = cocos2d::GLProgramState::getOrCreateWithGLProgram(glprogram);
		water->setGLProgramState(glprogramstate);

		glprogramstate->setUniformTexture("u_wave1", wave1);
		glprogramstate->setUniformTexture("u_wave2", wave2);
		glprogramstate->setUniformFloat("saturateValue", saturation);
		glprogramstate->setUniformFloat("verticalSpeed", vSpeed);
		glprogramstate->setUniformFloat("horizontalSpeed", hSpeed);


		return water;
	}
	CC_SAFE_DELETE(water);
	return nullptr;
}
示例#15
0
void MainWindow::on_actionOpen_triggered() {
	QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
                                                    "/data", tr("Images (*.nrrd)"));
	if (fileName != NULL) {
		addImage(fileName);
	}
}
示例#16
0
void ofxSlitScan::addImage(ofPixels& image){
	if(image.getImageType() != type){
		ofLog(OF_LOG_ERROR, "ofxSlitScan -- adding image of the wrong type");
		return;
	}
	addImage( image.getPixels() );
}
示例#17
0
bool StitcherView::loadImage(QString s){
  Image * a =  sp_image_read(s.toAscii(),0);
  ImageItem * item = new ImageItem(a,s,this,NULL);
  addImage(item);    
  item->update();
  return true;
}
示例#18
0
bool Sprite3D::loadFromC3x(const std::string& path)
{
    std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path);
    //find from the cache
    std::string key = fullPath + "#";
    auto mesh = MeshCache::getInstance()->getMesh(key);
    if (mesh)
    {
        _mesh = mesh;
        _mesh->retain();
        
        auto tex = Sprite3DMaterialCache::getInstance()->getSprite3DMaterial(key);
        setTexture(tex);
        
        _skin = MeshSkin::create(fullPath, "");
        CC_SAFE_RETAIN(_skin);
        
        genGLProgramState();
        
        return true;
    }
    
    //load from .c3b or .c3t
    auto bundle = Bundle3D::getInstance();
    if (!bundle->load(fullPath))
        return false;
    
    MeshData meshdata;
    bool ret = bundle->loadMeshData("", &meshdata);
    if (!ret)
    {
        return false;
    }
    
    _mesh = Mesh::create(meshdata.vertex, meshdata.vertexSizeInFloat, meshdata.indices, meshdata.attribs);
    CC_SAFE_RETAIN(_mesh);
    
    _skin = MeshSkin::create(fullPath, "");
    CC_SAFE_RETAIN(_skin);
    
    MaterialData materialdata;
    ret = bundle->loadMaterialData("", &materialdata);
    if (ret)
    {
        setTexture(materialdata.texturePath);
    }
    
    genGLProgramState();
    
    //add to cache
    auto cache = Director::getInstance()->getTextureCache();
    auto tex = cache->addImage(materialdata.texturePath);
    if (tex)
        Sprite3DMaterialCache::getInstance()->addSprite3DMaterial(key, tex);
    
    MeshCache::getInstance()->addMesh(key, _mesh);
    
    return true;
}
示例#19
0
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent) {
	ui.setupUi(this);

    m_particleColors = new QActionGroup(this);
    m_particleColors->addAction(ui.actionParticleBlack);
    m_particleColors->addAction(ui.actionParticleRed);
    m_particleColors->addAction(ui.actionParticleGreen);
    m_particleColors->addAction(ui.actionParticleBlue);
    m_particleColors->addAction(ui.actionParticleWhite);
    m_particleColors->addAction(ui.actionParticleHSV);
    ui.actionParticleHSV->setChecked(true);

    //    QSize gvSize = ui.graphicsView->size();
    //    ui.graphicsView->setSceneRect(0, 0, gvSize.width(), gvSize.height());
    //    qDebug() << "Scene Rect: " << ui.graphicsView->sceneRect();
	ui.graphicsView->setScene(&gs);
	ui.graphicsView->setRenderHints(
                                    QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
	ui.graphicsView->scale(2, 2);
    ui.graphicsView->setBackgroundBrush(QBrush(Qt::black, Qt::SolidPattern));
    //	addImage(tr("/base/imageParticles/data/12.T2.slice.nrrd"));
    //	addImage(tr("/base/imageParticles/data/13.T2.slice.nrrd"));

#ifdef __APPLE__
    addImage(tr("/data/2D/circle.jpg"));
    loadMask(tr("/data/2D/circle-boundary.png"));
    addImage(tr("/data/2D/circle.jpg"));
    loadMask(tr("/data/2D/random-boundary.jpg"));
#else
    addImage(tr("/base/imageParticles/data/10.T2.slice.nrrd"));
    addImage(tr("/base/imageParticles/data/circle.jpg"));
    loadMask(tr("/base/imageParticles/data/circle-boundary.png"));
    loadMask(tr("/base/imageParticles/data/random-boundary.jpg"));
#endif

    QObject::connect(&m_Timer, SIGNAL(timeout()), this, SLOT(particleAnimationTimeout()));
    QObject::connect(ui.actionShowImage, SIGNAL(triggered()), this, SLOT(updateScene()));
    QObject::connect(ui.actionShowShapeMask, SIGNAL(triggered()), this, SLOT(updateScene()));
    QObject::connect(ui.actionShowShapeDistanceMap, SIGNAL(triggered()), this, SLOT(updateScene()));
    QObject::connect(m_particleColors, SIGNAL(triggered(QAction*)), this, SLOT(updateScene()));
    QObject::connect(ui.actionShowPhantomParticles, SIGNAL(triggered()), this, SLOT(updateScene()));

    ui.listWidget->setCurrentRow(0);
}
// readFileLists reads the srclist file specified in params
// and reads the names of the images and fitpsf 
void MultiShearCatalog::readFileLists()
{
    std::string file = _params.get("coadd_srclist");
    if (!DoesFileExist(file)) {
        throw FileNotFoundException(file);
    }

    try {
        dbg<<"Opening coadd srclist\n";
        std::ifstream flist(file.c_str(), std::ios::in);
        if (!flist) {
            throw ReadException("Unable to open source list file " + file);
        }

        _image_file_list.clear();
        _shear_file_list.clear();
        _fitpsf_file_list.clear();
        _skymap_file_list.clear();

        std::string image_filename;
        std::string shear_filename;
        std::string fitpsf_filename;
        std::string skymap_filename;
        bool isSkyMapIn_list = _params.read("multishear_skymap_in_list",false);

        while (flist >> image_filename >> shear_filename >> fitpsf_filename) {
            dbg<<"Files are :\n"<<image_filename<<std::endl;
            dbg<<shear_filename<<std::endl;
            dbg<<fitpsf_filename<<std::endl;
            if (isSkyMapIn_list) {
                flist >> skymap_filename;
                if (!flist) {
                    throw ReadException(
                        "Unable to read skymap_filename in list file " + file);
                }
                addImage(image_filename,fitpsf_filename,
                         shear_filename,skymap_filename);
            } else {
                addImage(image_filename,fitpsf_filename,shear_filename);
            }
        }
        if (isSkyMapIn_list) {
            Assert(_skymap_file_list.size() == _image_file_list.size());
        }
    } catch (std::exception& e) {
示例#21
0
LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string& url,
												   BOOL usemipmaps,
												   LLViewerTexture::EBoostLevel boost_priority,
												   S8 texture_type,
												   LLGLint internal_format,
												   LLGLenum primary_format, 
												   const LLUUID& force_id)
{
	// generate UUID based on hash of filename
	LLUUID new_id;
	if (force_id.notNull())
	{
		new_id = force_id;
	}
	else
	{
		new_id.generate(url);
	}

	LLPointer<LLViewerFetchedTexture> imagep = findImage(new_id);
	
	if (imagep.isNull())
	{
		switch(texture_type)
		{
		case LLViewerTexture::FETCHED_TEXTURE:
			imagep = new LLViewerFetchedTexture(url, new_id, usemipmaps);
			break ;
		case LLViewerTexture::LOD_TEXTURE:
			imagep = new LLViewerLODTexture(url, new_id, usemipmaps);
			break ;
		default:
			llerrs << "Invalid texture type " << texture_type << llendl ;
		}		
		
		if (internal_format && primary_format)
		{
			imagep->setExplicitFormat(internal_format, primary_format);
		}

		addImage(imagep);
		
		if (boost_priority != 0)
		{
			if (boost_priority == LLViewerFetchedTexture::BOOST_UI ||
				boost_priority == LLViewerFetchedTexture::BOOST_ICON)
			{
				imagep->dontDiscard();
			}
			imagep->setBoostLevel(boost_priority);
		}
	}

	imagep->setGLTextureCreated(true);

	return imagep;
}
void AssetManager::setup(ofxXmlSettings& XML) {
	// load character-images:
	string tempFileName = XML.getValue("GAME:MAP:PLAYERS:PLAYER_1:SPRITESHEET", "");
	if(addImage(tempFileName, tempFileName, CHARACTER))
		cout << "Added " << tempFileName << " to character-images" << endl;

	tempFileName = XML.getValue("GAME:MAP:PLAYERS:PLAYER_2:SPRITESHEET", "");
	if(addImage(tempFileName, tempFileName, CHARACTER))
		cout << "Added " << tempFileName << " to character-images" << endl;

	tempFileName = XML.getValue("GAME:MAP:PLAYERS:ENEMY_1:SPRITESHEET", "");
	if(addImage(tempFileName, tempFileName, CHARACTER))
		cout << "Added " << tempFileName << " to character-images" << endl;

	// get grid-size of the map:
	int tileCountX = XML.getValue("GAME:MAP:GRID:X", 0);
	int tileCountY = XML.getValue("GAME:MAP:GRID:Y", 0);

	// load tile-images:
	XML.pushTag("GAME");
	XML.pushTag("MAP");
	XML.pushTag("TILES");
	XML.pushTag("DATA");

	for(int i = 0; i < tileCountX * tileCountY; i++) {
		string tempFileName = XML.getValue("TILE:PATH", "error.png", i);

		if(addImage(tempFileName, tempFileName, TILE))
			cout << "Added " << tempFileName << " to tile-images" << endl;
	}

	XML.popTag(); // DATA
	XML.popTag(); // TILES
	XML.popTag(); // MAP
	XML.popTag(); // GAME

	// load background-music:
	string bgMusicPath = XML.getValue("GAME:SETTINGS:BACKGROUND_MUSIC", "");
	if(addSound(bgMusicPath, bgMusicPath)) {
		cout << "Added " << bgMusicPath << " as background-music" << endl;
	}

	printf("AssetManager: Done with setup()\n");
}
示例#23
0
文件: CMP_glare.c 项目: jinjoh/NOOR
static void streaks(NodeGlare* ndg, CompBuf* dst, CompBuf* src)
{
	CompBuf *bsrc, *tsrc, *tdst, *sbuf;
	int x, y, n;
	unsigned int nump=0;
	fRGB c1, c2, c3, c4;
	float a, ang = 360.f/(float)ndg->angle;

	bsrc = BTP(src, ndg->threshold, 1 << ndg->quality);
	tsrc = dupalloc_compbuf(bsrc); // sample from buffer
	tdst = alloc_compbuf(tsrc->x, tsrc->y, tsrc->type, 1); // sample to buffer
	sbuf = alloc_compbuf(tsrc->x, tsrc->y, tsrc->type, 1);  // streak sum buffer

	
	for (a=0.f; a<360.f; a+=ang) {
		const float an = (a + (float)ndg->angle_ofs)*(float)M_PI/180.f;
		const float vx = cos((double)an), vy = sin((double)an);
		for (n=0; n<ndg->iter; ++n) {
			const float p4 = pow(4.0, (double)n);
			const float vxp = vx*p4, vyp = vy*p4;
			const float wt = pow((double)ndg->fade, (double)p4);
			const float cmo = 1.f - pow((double)ndg->colmod, (double)n+1);	// colormodulation amount relative to current pass
			float* tdstcol = tdst->rect;
			for (y=0; y<tsrc->y; ++y) {
				for (x=0; x<tsrc->x; ++x, tdstcol+=4) {
					// first pass no offset, always same for every pass, exact copy,
					// otherwise results in uneven brightness, only need once
					if (n==0) qd_getPixel(tsrc, x, y, c1); else c1[0]=c1[1]=c1[2]=0;
					qd_getPixelLerp(tsrc, x + vxp,     y + vyp,     c2);
					qd_getPixelLerp(tsrc, x + vxp*2.f, y + vyp*2.f, c3);
					qd_getPixelLerp(tsrc, x + vxp*3.f, y + vyp*3.f, c4);
					// modulate color to look vaguely similar to a color spectrum
					fRGB_rgbmult(c2, 1.f, cmo, cmo);
					fRGB_rgbmult(c3, cmo, cmo, 1.f);
					fRGB_rgbmult(c4, cmo, 1.f, cmo);
					tdstcol[0] = 0.5f*(tdstcol[0] + c1[0] + wt*(c2[0] + wt*(c3[0] + wt*c4[0])));
					tdstcol[1] = 0.5f*(tdstcol[1] + c1[1] + wt*(c2[1] + wt*(c3[1] + wt*c4[1])));
					tdstcol[2] = 0.5f*(tdstcol[2] + c1[2] + wt*(c2[2] + wt*(c3[2] + wt*c4[2])));
				}
			}
			memcpy(tsrc->rect, tdst->rect, sizeof(float)*tdst->x*tdst->y*tdst->type);
		}

		addImage(sbuf, tsrc, 1.f/(float)(6 - ndg->iter));
		memset(tdst->rect, 0, tdst->x*tdst->y*tdst->type*sizeof(float));
		memcpy(tsrc->rect, bsrc->rect, bsrc->x*bsrc->y*bsrc->type*sizeof(float));
		nump++;
	}

	mixImages(dst, sbuf, 0.5f + 0.5f*ndg->mix);

	free_compbuf(tsrc);
	free_compbuf(tdst);
	free_compbuf(sbuf);
	free_compbuf(bsrc);
}
示例#24
0
void ImageScanner::newFile(int albumId)
{
    loadFromDisk();
    addImage(albumId);

    if (!scanFromIdenticalFile())
    {
        scanFile(NewScan);
    }
}
示例#25
0
LLViewerImage* LLViewerImageList::getImageFromFile(const std::string& filename,
												   BOOL usemipmaps,
												   BOOL level_immediate,
												   LLGLint internal_format,
												   LLGLenum primary_format, 
												   const LLUUID& force_id)
{
	if (gNoRender)
	{
		// Never mind that this ignores image_set_id;
		// getImage() will handle that later.
		return getImage(IMG_DEFAULT, TRUE, TRUE);
	}

	std::string full_path = gDirUtilp->findSkinnedFilename("textures", filename);
	if (full_path.empty())
	{
		llwarns << "Failed to find local image file: " << filename << llendl;
		return getImage(IMG_DEFAULT, TRUE, TRUE);
	}

	// generate UUID based on hash of filename
	LLUUID new_id;
	if (force_id.notNull())
	{
		new_id = force_id;
	}
	else
	{
		new_id.generate(full_path);
	}

	LLPointer<LLViewerImage> imagep = hasImage(new_id);
	
	if (imagep.isNull())
	{
		imagep = new LLViewerImage(full_path, new_id, usemipmaps);
		
		if (internal_format && primary_format)
		{
			imagep->setExplicitFormat(internal_format, primary_format);
		}

		addImage(imagep);
		
		if (level_immediate)
		{
			imagep->dontDiscard();
			imagep->setBoostLevel(LLViewerImage::BOOST_UI);
		}
	}

	return imagep;
}
示例#26
0
void Machine::loadFromJson(std::string const &path) {
  Json file;

  file.load(path);
  Json::Object const &data = file;
  for (auto p : data) {
    Json::Array const &imgPaths = p.second;
    for (std::string const &path : imgPaths)
      addImage(p.first, path);
  }
}
示例#27
0
void CMyPaintDoc::saveState() {
  CHECKINVARIANT;

  if(canAddImage()) {
    while(canRedo()) {
      removeLast();
    }
    addImage();
    m_index = getHistorySize();
  }
  CHECKINVARIANT;
}
示例#28
0
CVImage::CVImage( VAttrListPosn &posn )
{
	VImage image;

	for ( ; VAttrExists ( & posn ) && ( VGetAttrRepn ( & posn ) == VImageRepn ); VNextAttr ( & posn ) ) {
		const VBoolean result = VGetAttrValue ( &posn, NULL, VImageRepn, &image );
		assert( result );

		if( !images.empty() && !fit( image ) )break;
		else addImage( image );
	}
}
    //---------------------------------------------------------------
    void ImageExporter::doExport()
    {
        // export all wire frame color materials

        for ( ExportedImageMap::const_iterator it = mExportedImageMap.begin(); it != mExportedImageMap.end(); ++it )
        {
			const ImageInfo& imageInfo = it->second;
            addImage ( COLLADASW::Image ( imageInfo.fileLocation, imageInfo.imageId ) );
        }

        closeLibrary();
    }
示例#30
0
void CreateBlogMsg::setupInsertActions()
{
    QMenu *menu = new QMenu(tr("&Insert"), this);
    menuBar()->addMenu(menu);

    QAction *a;

    a = new QAction(QIcon(""), tr("&Image"), this);
    connect(a, SIGNAL(triggered()), this, SLOT(addImage()));
    menu->addAction(a);

}