A Vector has been replaced.
This commit is contained in:
@ -37,30 +37,30 @@ using namespace lout::container::typed;
|
||||
const enum ScaleMode { SIMPLE, BEAUTIFUL, BEAUTIFUL_GAMMA }
|
||||
scaleMode = BEAUTIFUL_GAMMA;
|
||||
|
||||
Vector <FltkImgbuf::GammaCorrectionTable> *FltkImgbuf::gammaCorrectionTables
|
||||
= new Vector <FltkImgbuf::GammaCorrectionTable> (true, 2);
|
||||
std::vector< std::unique_ptr< FltkImgbuf::GammaCorrectionTable > > FltkImgbuf::gammaCorrectionTables;
|
||||
|
||||
uchar *FltkImgbuf::findGammaCorrectionTable (double gamma)
|
||||
{
|
||||
// Since the number of possible keys is low, a linear search is
|
||||
// sufficiently fast.
|
||||
|
||||
for (int i = 0; i < gammaCorrectionTables->size(); i++) {
|
||||
GammaCorrectionTable *gct = gammaCorrectionTables->get(i);
|
||||
for (std::size_t i = 0; i < gammaCorrectionTables.size(); i++) {
|
||||
GammaCorrectionTable *gct = gammaCorrectionTables.at(i).get();
|
||||
if (gct->gamma == gamma)
|
||||
return gct->map;
|
||||
}
|
||||
|
||||
_MSG("Creating new table for gamma = %g\n", gamma);
|
||||
|
||||
GammaCorrectionTable *gct = new GammaCorrectionTable();
|
||||
auto gct = std::make_unique< GammaCorrectionTable >();
|
||||
gct->gamma = gamma;
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
gct->map[i] = 255 * pow((double)i / 255, gamma);
|
||||
|
||||
gammaCorrectionTables->put (gct);
|
||||
return gct->map;
|
||||
auto *rv= gct->map;
|
||||
gammaCorrectionTables.push_back (std::move(gct));
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool FltkImgbuf::excessiveImageDimensions (int width, int height)
|
||||
@ -72,8 +72,7 @@ bool FltkImgbuf::excessiveImageDimensions (int width, int height)
|
||||
void FltkImgbuf::freeall ()
|
||||
{
|
||||
_MSG("Deleting gammaCorrectionTables\n");
|
||||
delete gammaCorrectionTables;
|
||||
gammaCorrectionTables = NULL;
|
||||
gammaCorrectionTables.clear();
|
||||
}
|
||||
|
||||
FltkImgbuf::FltkImgbuf (Type type, int width, int height, double gamma)
|
||||
|
||||
@ -36,8 +36,7 @@ private:
|
||||
// the image buffer.
|
||||
lout::misc::BitSet *copiedRows;
|
||||
|
||||
static lout::container::typed::Vector <GammaCorrectionTable>
|
||||
*gammaCorrectionTables;
|
||||
static std::vector< std::unique_ptr< GammaCorrectionTable > > gammaCorrectionTables;
|
||||
|
||||
static uchar *findGammaCorrectionTable (double gamma);
|
||||
static bool excessiveImageDimensions (int width, int height);
|
||||
|
||||
Reference in New Issue
Block a user