wxImageCache.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00027 #include "wxImageCache.h"
00028 #include "vigra_ext/utils.h"
00029 
00030 wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)
00031 {
00032     if (e->imageFloat->size().area() > 0)
00033     {
00034         // for float images we need to apply the mapping as selected by the user
00035         // in the preferences
00036         const int mapping = wxConfigBase::Get()->Read(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT);
00037         // find min/max
00038         vigra::RGBToGrayAccessor<vigra::RGBValue<float> > ga;
00039         vigra::FindMinMax<float> minmax;   // init functor
00040         vigra::inspectImage(srcImageRange(*(e->imageFloat), ga), minmax);
00041         // create temporary image with remapped tone scale
00042         vigra::BRGBImage mappedImg(e->imageFloat->size());
00043         vigra_ext::applyMapping(srcImageRange(*(e->imageFloat)), destImage(mappedImg), std::max(minmax.min, 1e-6f), minmax.max, mapping);
00044         // convert to wxImage
00045         wxImage mappedwxImg(mappedImg.width(), mappedImg.height(), (unsigned char *)mappedImg.data(), true);
00046         return mappedwxImg.Copy();
00047     }
00048     else
00049     {
00050         ImageCacheRGB8Ptr img = e->get8BitImage();
00051         if (img)
00052         {
00053             return wxImage(img->width(), img->height(), (unsigned char *)img->data(), true);
00054         }
00055         else
00056         {
00057             // invalid wxImage
00058             return wxImage();
00059         };
00060     };
00061 }
00062 

Generated on 7 Dec 2016 for Hugintrunk by  doxygen 1.4.7