QVariant QgsDataDefinedSizeLegendNode::data( int role ) const { if ( role == Qt::DecorationRole ) { cacheImage(); return QPixmap::fromImage( mImage ); } else if ( role == Qt::SizeHintRole ) { cacheImage(); return mImage.size(); } return QVariant(); }
int Cache::free(fim::Image* oi) { /* acca' nun stimm'a'ppazzia' */ if(!oi)return -1; if(!is_in_cache(oi)) { #if 0 /* if the image is not already one of ours, it * is probably a cloned one, and the caller * didn't know this. * * in this case we keep it in the cache, * so it could be useful in the future. * */ if( oi->revertToLoaded() )//removes internal scale caches cacheImage( oi ); //FIXME : validity should be checked .. #else delete oi; #endif return 0; } /* * fixme : we should explicitly mark for deletion someday.. * */ //if(need_free())return erase(oi); /* careful here !! */ //if(need_free())free_some_lru(); else return 0; /* no free needed */ }
QImage QgsSvgCache::svgAsImage( const QString &file, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio ) { QMutexLocker locker( &mMutex ); fitsInCache = true; QgsSvgCacheEntry *currentEntry = cacheEntry( file, size, fill, stroke, strokeWidth, widthScaleFactor, fixedAspectRatio ); QImage result; //if current entry image is 0: cache image for entry // checks to see if image will fit into cache //update stats for memory usage if ( !currentEntry->image ) { QSvgRenderer r( currentEntry->svgContent ); double hwRatio = 1.0; if ( r.viewBoxF().width() > 0 ) { if ( currentEntry->fixedAspectRatio > 0 ) { hwRatio = currentEntry->fixedAspectRatio; } else { hwRatio = r.viewBoxF().height() / r.viewBoxF().width(); } } long cachedDataSize = 0; cachedDataSize += currentEntry->svgContent.size(); cachedDataSize += static_cast< int >( currentEntry->size * currentEntry->size * hwRatio * 32 ); if ( cachedDataSize > MAXIMUM_SIZE / 2 ) { fitsInCache = false; currentEntry->image.reset(); // instead cache picture if ( !currentEntry->picture ) { cachePicture( currentEntry, false ); } // ...and render cached picture to result image result = imageFromCachedPicture( *currentEntry ); } else { cacheImage( currentEntry ); result = *( currentEntry->image ); } trimToMaximumSize(); } else { result = *( currentEntry->image ); } return result; }
double ossimNetCdfReader::getMaxPixelValue(ossim_uint32 band)const { cacheImage(); if(theMemoryTile.valid()) { return theMemoryTile->getMaxPix(band); } return ossimImageHandler::getMaxPixelValue(band); }
ossimScalarType ossimNetCdfReader::getOutputScalarType() const { cacheImage(); if(theMemoryTile.valid()) { return theMemoryTile->getScalarType(); } return ossimImageHandler::getOutputScalarType(); }
ossim_uint32 ossimNetCdfReader::getNumberOfInputBands() const { ossim_uint32 result = 0; cacheImage(); if(theMemoryTile.valid()) { result = theMemoryTile->getNumberOfBands(); } return result; }
characterImageCache* characterImageManager::getShirtImage(int shirtID) { //Returns the specified face image cache std::string graphicPath; std::string dataPath; char buffer[256]; int n; n= sprintf(buffer,":character:equipment:%i.png",shirtID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:equipmentSpriteData:%i.raw",shirtID); dataPath = std::string(buffer,n); return cacheImage(graphicPath,dataPath); }
characterImageCache* characterImageManager::getMouthImage(int mouthID) { //Returns the specified face image cache std::string graphicPath; std::string dataPath; char buffer[256]; int n; n= sprintf(buffer,":character:mouth:%i.png",mouthID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:mouth:%i.raw",mouthID); dataPath = std::string(buffer,n); return cacheImage(graphicPath,dataPath); }
characterImageCache* characterImageManager::getFacialHairImage(int facialHairID, int facialHairColor) { //Returns the specified face image cache std::string graphicPath; std::string dataPath; char buffer[256]; int n; n= sprintf(buffer,":character:facialHair:%i:%i.png",facialHairID,facialHairColor); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:facialHair:%i:calibration.raw",facialHairID); dataPath = std::string(buffer,n); return cacheImage(graphicPath,dataPath); }
characterImageCache* characterImageManager::getHairImage(int hairID, int hairColor) { //Returns the hair for the specified gender, hairtype and haircolor std::string graphicPath; std::string dataPath; char buffer[256]; int n; n= sprintf(buffer,":character:hair:%i:%i.png",hairID,hairColor); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:hair:%i:calibration.raw",hairID); dataPath = std::string(buffer,n); return cacheImage(graphicPath,dataPath); }
const QImage& QgsSvgCache::svgAsImage( const QString& file, int size, const QColor& fill, const QColor& outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor ) { QgsSvgCacheEntry* currentEntry = cacheEntry( file, size, fill, outline, outlineWidth, widthScaleFactor, rasterScaleFactor ); //if current entry image is 0: cache image for entry //update stats for memory usage if ( !currentEntry->image ) { cacheImage( currentEntry ); trimToMaximumSize(); } return *( currentEntry->image ); }
shared_ptr<Image> IndexedImage::scaled( int width, int height ) { int srcWidth = getWidth(); int srcHeight = getHeight(); // no need to scale if(srcWidth == width && srcHeight == height){ return this->shared_from_this(); } Dimension d(width, height); shared_ptr<Image> i = getCachedImage(d); // currently we only support byte data... i = new IndexedImage(width, height, palette, scaleArray(imageDataByte, width, height)); cacheImage(d, i); return i; }
ossim_uint32 ossimLibRawReader::getNumberOfLines(ossim_uint32 reduced_res_level) const { cacheImage(); if (reduced_res_level == 0) { if(theMemoryTile.valid()) { return theMemoryTile->getHeight(); } } else if ( theOverview.valid() ) { return theOverview->getNumberOfLines(reduced_res_level); } return 0; }
ossim_uint32 ossimNetCdfReader::getNumberOfSamples(ossim_uint32 reduced_res_level) const { cacheImage(); if (reduced_res_level == 0) { if(theMemoryTile.valid()) { return theMemoryTile->getWidth(); } } else if ( theOverview.valid() ) { return theOverview->getNumberOfSamples(reduced_res_level); } return 0; }
characterImageCache* characterImageManager::getShoeImage(int shoeID, bool facing) { //Returns the specified face image cache std::string graphicPath; std::string dataPath; char buffer[256]; int n; if (facing) { n= sprintf(buffer,":character:equipment:%i-1.png",shoeID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:equipmentSpriteData:%i-1.raw",shoeID); dataPath = std::string(buffer,n); }else{ n= sprintf(buffer,":character:equipment:%i-0.png",shoeID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:equipmentSpriteData:%i-0.raw",shoeID); dataPath = std::string(buffer,n); } return cacheImage(graphicPath,dataPath); }
const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool& fitsInCache ) { QMutexLocker locker( &mMutex ); fitsInCache = true; QgsSvgCacheEntry* currentEntry = cacheEntry( file, size, fill, outline, outlineWidth, widthScaleFactor, rasterScaleFactor ); //if current entry image is 0: cache image for entry // checks to see if image will fit into cache //update stats for memory usage if ( !currentEntry->image ) { QSvgRenderer r( currentEntry->svgContent ); double hwRatio = 1.0; if ( r.viewBoxF().width() > 0 ) { hwRatio = r.viewBoxF().height() / r.viewBoxF().width(); } long cachedDataSize = 0; cachedDataSize += currentEntry->svgContent.size(); cachedDataSize += ( int )( currentEntry->size * currentEntry->size * hwRatio * 32 ); if ( cachedDataSize > mMaximumSize / 2 ) { fitsInCache = false; delete currentEntry->image; currentEntry->image = 0; //currentEntry->image = new QImage( 0, 0 ); // instead cache picture if ( !currentEntry->picture ) { cachePicture( currentEntry, false ); } } else { cacheImage( currentEntry ); } trimToMaximumSize(); } return *( currentEntry->image ); }
bool ossimNetCdfReader::getTile(ossimImageData* result, ossim_uint32 resLevel) { bool status = false; status = getOverviewTile(resLevel, result); ossimIrect rect = result->getImageRectangle(); if (!status) // Did not get an overview tile. { if(!theTile.valid()||!theMemoryTile.valid()) { cacheImage(); } if (theTile.valid()) { // Image rectangle must be set prior to calling getTile. theTile->setImageRectangle(rect); theTile->makeBlank(); ossimIrect memRect = theMemoryTile->getImageRectangle(); if(memRect.intersects(rect)) { ossimIrect clampRect = theMemoryTile->getImageRectangle().clipToRect(rect); theTile->loadTile(theMemoryTile->getBuf(), memRect, OSSIM_BSQ); theTile->validate(); status = true; } } } return status; }
ossimRefPtr<ossimImageData> ossimNetCdfReader::getTile( const ossimIrect& tile_rect, ossim_uint32 resLevel) { if(!theTile.valid()||!theMemoryTile.valid()) { cacheImage(); } if (theTile.valid()) { // Image rectangle must be set prior to calling getTile. theTile->setImageRectangle(tile_rect); if ( getTile( theTile.get(), resLevel ) == false ) { if (theTile->getDataObjectStatus() != OSSIM_NULL) { theTile->makeBlank(); } } } return theTile; }
void CachedImage::start() { cacheImage(); }
characterImageCache* characterImageManager::getSkinImage(int raceID, int skinColorID, bodyPart part) { //Returns the specified body part of thr specified skin. std::string graphicPath; std::string dataPath; char buffer[256]; int n; switch (part) { case BODY_BODY: n= sprintf(buffer,":character:race:%i:skinColor:%i:Body.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:Body.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_FACE: n= sprintf(buffer,":character:race:%i:skinColor:%i:Face.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:Face.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_FACINGFOOT: n= sprintf(buffer,":character:race:%i:skinColor:%i:FacingFoot.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:FacingFoot.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_HEAD: n= sprintf(buffer,":character:race:%i:skinColor:%i:Head.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:Head.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_LEFTHAND: n= sprintf(buffer,":character:race:%i:skinColor:%i:LeftHand.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:LeftHand.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_RIGHTHAND: n= sprintf(buffer,":character:race:%i:skinColor:%i:RightHand.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:RightHand.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_CLOSEDHAND: n= sprintf(buffer,":character:race:%i:skinColor:%i:HandClosed.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:HandClosed.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_STRAIGHTFOOT: n= sprintf(buffer,":character:race:%i:skinColor:%i:StraightFoot.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:StraightFoot.raw",raceID); dataPath = std::string(buffer,n); break; case BODY_EAR: n= sprintf(buffer,":character:race:%i:skinColor:%i:Ear.png",raceID,skinColorID); graphicPath = std::string(buffer,n); n= sprintf(buffer,":character:race:%i:Ear.raw",raceID); dataPath = std::string(buffer,n); break; default: std::cout << "ERROR generating image cache for race. Unknown body part: " << part << std::endl; } return cacheImage(graphicPath,dataPath); }