A Vector has been replaced.

This commit is contained in:
2025-03-13 22:26:15 -04:00
parent 9be23f8360
commit 40e2306664
3 changed files with 13 additions and 15 deletions

View File

@ -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)