void GPUImage::setBitmap(BitmapPtr pBmp, TexCompression comp) { assertValid(); if (!pBmp) { throw Exception(AVG_ERR_UNSUPPORTED, "setBitmap(): bitmap must not be None!"); } if (comp == TEXCOMPRESSION_B5G6R5 && pBmp->hasAlpha()) { throw Exception(AVG_ERR_UNSUPPORTED, "B5G6R5-compressed textures with an alpha channel are not supported."); } unload(); changeSource(BITMAP); m_pBmp = BitmapPtr(new Bitmap(pBmp->getSize(), pBmp->getPixelFormat(), "")); m_pBmp->copyPixels(*pBmp); if (comp == TEXCOMPRESSION_B5G6R5) { BitmapPtr pDestBmp = BitmapPtr(new Bitmap(pBmp->getSize(), B5G6R5, "")); if (!BitmapLoader::get()->isBlueFirst()) { FilterFlipRGB().applyInPlace(m_pBmp); } pDestBmp->copyPixels(*m_pBmp); m_pBmp = pDestBmp; } if (m_State == GPU) { setupBitmapSurface(); } assertValid(); }
void GPUImage::setEmpty() { assertValid(); unload(); changeSource(NONE); assertValid(); }
void Image::setFilename(const std::string& sFilename, TextureCompression comp) { assertValid(); AVG_TRACE(Logger::category::MEMORY, Logger::severity::INFO, "Loading " << sFilename); BitmapPtr pBmp = loadBitmap(sFilename); if (comp == TEXTURECOMPRESSION_B5G6R5 && pBmp->hasAlpha()) { throw Exception(AVG_ERR_UNSUPPORTED, "B5G6R5-compressed textures with an alpha channel are not supported."); } changeSource(FILE); m_pBmp = pBmp; m_sFilename = sFilename; switch (comp) { case TEXTURECOMPRESSION_B5G6R5: m_pBmp = BitmapPtr(new Bitmap(pBmp->getSize(), B5G6R5, sFilename)); if (!BitmapLoader::get()->isBlueFirst()) { FilterFlipRGB().applyInPlace(pBmp); } m_pBmp->copyPixels(*pBmp); break; case TEXTURECOMPRESSION_NONE: break; default: assert(false); } if (m_State == GPU) { m_pSurface->destroy(); setupSurface(); } assertValid(); }
ToolImage::ToolImage() : Tool(), currentImageElement(NULL), newImageAction(NULL), itMustPlaceNewImage(false) { QVBoxLayout *layout; QToolBar *tool_bar; name = "Image tool"; imageName = ":/images/tool_image.png"; itAcceptsDrop = true; widget = new QWidget(); layout = new QVBoxLayout(); layout->addWidget(new QLabel("Insert:")); tool_bar = new QToolBar(); newImageAction = tool_bar->addAction(QIcon(), "New", this, SLOT(insertNew())); newImageAction->setCheckable(true); layout->addWidget(tool_bar); layout->addWidget(new QLabel("Modify:")); tool_bar = new QToolBar(); tool_bar->addAction(QIcon(), "Change source", this, SLOT(changeSource())); layout->addWidget(tool_bar); widget->setLayout(layout); }
void Image::setEmpty() { assertValid(); if (m_State == GPU) { m_pSurface->destroy(); } changeSource(NONE); assertValid(); }
void Image::setCanvas(OffscreenCanvasPtr pCanvas) { assertValid(); if (m_Source == SCENE && pCanvas == m_pCanvas) { return; } changeSource(SCENE); m_pCanvas = pCanvas; if (m_State == GPU) { m_pSurface->create(B8G8R8X8, m_pCanvas->getTex(), MCTexturePtr(), MCTexturePtr(), MCTexturePtr(), true); } assertValid(); }
const char *LH_TS3MuteImage::userInit() { if( const char *err = LH_QImage::userInit() ) return err; //setup_show_placeholder_->setTitle("Use default images"); setup_mute_source_ = new LH_Qt_QStringList(this, "Mute Source", QStringList() << "Speakers" << "Microphone", LH_FLAG_NOSINK | LH_FLAG_NOSOURCE | LH_FLAG_AUTORENDER); setup_mute_status_ = new LH_Qt_QStringList(this, "Mute Status", QStringList() << "N/A" << "None" << "Muted" << "Active", LH_FLAG_HIDDEN | LH_FLAG_READONLY | LH_FLAG_NOSOURCE | LH_FLAG_NOSAVE | LH_FLAG_AUTORENDER); setup_mute_status_->setLink("=/3rdParty/TeamSpeak 3/Speaker Status"); connect(setup_mute_source_, SIGNAL(changed()), this, SLOT(changeSource())); add_cf_target(setup_image_file_); add_cf_source(setup_mute_status_); return 0; }
SourceImageLoader::SourceImageLoader() { string path = "sources"; ofDirectory dir(path); dir.listDir(); // Store the directories and the names of them. for(int i = 0; i < dir.size(); i++) { vector<string> results = ofSplitString(dir.getPath(i), "/"); sourceDirectories.push_back(dir.getPath(i)); sourceDirLabels.push_back(results[1]); } // Load defaults // Grass is the default activeDirIndex = 1; changeSource(); };
void ToolImage::onFileDrop(const QString &url) { QFileInfo fileInfo(url); Element *element = RocketHelper::getElementUnderMouse(); if (element) { if (element->GetTagName() == "img") { changeSource(element,fileInfo.fileName()); } else { element = ToolDiv::getDivParent(element); if (element) { Rocket::Core::XMLAttributes attributes; attributes.Set("src", fileInfo.fileName().toAscii().data()); Element* img = Rocket::Core::Factory::InstanceElement(NULL, "img", "img", attributes); insertNew(img, element); } } } }
void Image::setBitmap(BitmapPtr pBmp, TextureCompression comp) { assertValid(); if (!pBmp) { throw Exception(AVG_ERR_UNSUPPORTED, "setBitmap(): bitmap must not be None!"); } if (comp == TEXTURECOMPRESSION_B5G6R5 && pBmp->hasAlpha()) { throw Exception(AVG_ERR_UNSUPPORTED, "B5G6R5-compressed textures with an alpha channel are not supported."); } bool bSourceChanged = changeSource(BITMAP); PixelFormat pf; switch (comp) { case TEXTURECOMPRESSION_NONE: pf = pBmp->getPixelFormat(); break; case TEXTURECOMPRESSION_B5G6R5: pf = B5G6R5; if (!BitmapLoader::get()->isBlueFirst()) { FilterFlipRGB().applyInPlace(pBmp); } break; default: assert(false); } m_pBmp = BitmapPtr(new Bitmap(pBmp->getSize(), pf, "")); m_pBmp->copyPixels(*pBmp); if (m_State == GPU) { MCTexturePtr pTex = m_pSurface->getTex(); if (bSourceChanged || m_pSurface->getSize() != m_pBmp->getSize() || m_pSurface->getPixelFormat() != pf) { pTex = GLContextManager::get()->createTexture(m_pBmp->getSize(), pf, m_Material.getUseMipmaps(), m_Material.getWrapSMode(), m_Material.getWrapTMode()); m_pSurface->create(pf, pTex); } GLContextManager::get()->scheduleTexUpload(pTex, m_pBmp); } assertValid(); }
void GPUImage::setFilename(const std::string& sFilename, TexCompression comp) { assertValid(); CachedImagePtr pImage = ImageCache::get()->getImage(sFilename, comp); BitmapPtr pBmp = pImage->getBmp(); if (comp == TEXCOMPRESSION_B5G6R5 && pBmp->hasAlpha()) { pImage->decBmpRef(); throw Exception(AVG_ERR_UNSUPPORTED, "B5G6R5-compressed textures with an alpha channel are not supported."); } unload(); m_pImage = pImage; m_pBmp = m_pImage->getBmp(); changeSource(FILE); m_sFilename = sFilename; if (m_State == GPU) { m_pSurface->destroy(); setupImageSurface(); } assertValid(); }