Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wxImageCache.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
27 #include "wxImageCache.h"
28 #include "vigra_ext/utils.h"
29 
30 wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)
31 {
32  if (e->imageFloat->size().area() > 0)
33  {
34  // for float images we need to apply the mapping as selected by the user
35  // in the preferences
36  const int mapping = wxConfigBase::Get()->Read(wxT("/ImageCache/Mapping"), HUGIN_IMGCACHE_MAPPING_FLOAT);
37  // find min/max
38  vigra::RGBToGrayAccessor<vigra::RGBValue<float> > ga;
39  vigra::FindMinMax<float> minmax; // init functor
40  vigra::inspectImage(srcImageRange(*(e->imageFloat), ga), minmax);
41  // create temporary image with remapped tone scale
42  vigra::BRGBImage mappedImg(e->imageFloat->size());
43  vigra_ext::applyMapping(srcImageRange(*(e->imageFloat)), destImage(mappedImg), std::max(minmax.min, 1e-6f), minmax.max, mapping);
44  // convert to wxImage
45  wxImage mappedwxImg(mappedImg.width(), mappedImg.height(), (unsigned char *)mappedImg.data(), true);
46  return mappedwxImg.Copy();
47  }
48  else
49  {
50  ImageCacheRGB8Ptr img = e->get8BitImage();
51  if (img)
52  {
53  return wxImage(img->width(), img->height(), (unsigned char *)img->data(), true);
54  }
55  else
56  {
57  // invalid wxImage
58  return wxImage();
59  };
60  };
61 }
62 
HuginBase::ImageCache::ImageCacheRGB8Ptr ImageCacheRGB8Ptr
Definition: wxImageCache.h:33
void applyMapping(vigra::triple< SrcIterator, SrcIterator, SrcAccessor > img, vigra::pair< DestIterator, DestAccessor > dest, T min, T max, int mapping)
Definition: utils.h:685
functions to manage ROI&#39;s
wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
Definition: ROIImage.h:324
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
Definition: ROIImage.h:287
static T max(T x, T y)
Definition: svm.cpp:65
#define HUGIN_IMGCACHE_MAPPING_FLOAT