This commit is contained in:
ffsup2
2010-10-03 19:52:27 +02:00
parent 23a8834755
commit 7c6de47f9d
39 changed files with 698 additions and 347 deletions

View File

@@ -116,18 +116,19 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h,
double avg_g = 0;
double avg_b = 0;
int n = 0;
int p = 6;
for (int i=1; i<img->height-1; i++)
for (int j=1; j<img->width-1; j++) {
int ofs = 3*(i*img->width + j);
if (img->data[ofs]>250 || img->data[ofs+1]>250 || img->data[ofs+2]>250)
int rtmp=img->data[ofs], gtmp=img->data[ofs+1], btmp=img->data[ofs+2];
if (rtmp>64000 || gtmp>64000 || btmp>64000)
continue;
avg_r += StdImageSource::intpow((double)img->data[ofs]*256, p);
avg_g += StdImageSource::intpow((double)img->data[ofs+1]*256, p);
avg_b += StdImageSource::intpow((double)img->data[ofs+2]*256, p);
avg_r += rtmp;
avg_g += gtmp;
avg_b += btmp;
n++;
}
ColorTemp::mul2temp (pow(avg_r/n, 1.0/p), pow(avg_g/n, 1.0/p), pow(avg_b/n, 1.0/p), tpp->autowbTemp, tpp->autowbGreen);
if (n>0)
ColorTemp::mul2temp (avg_r/n, avg_g/n, avg_b/n, tpp->autowbTemp, tpp->autowbGreen);
delete img;
tpp->init ();