调整GAMMA曲线使用

This commit is contained in:
gb 2023-08-07 15:52:33 +08:00
parent 75559888de
commit 3696107db7
1 changed files with 11 additions and 7 deletions

View File

@ -205,12 +205,11 @@ hg_scanner::hg_scanner(ScannerSerial serial, const char* dev_name, usb_io* io, i
custom_gamma_val_ = new SANE_Gamma; custom_gamma_val_ = new SANE_Gamma;
memset(custom_gamma_val_, 0, sizeof(SANE_Gamma)); memset(custom_gamma_val_, 0, sizeof(SANE_Gamma));
for (int i = 0; i < ARRAY_SIZE(custom_gamma_val_->table); ++i)
custom_gamma_val_->table[i] = i & 0x0ff;
paper_size_mm_.cx = 210; paper_size_mm_.cx = 210;
paper_size_mm_.cy = 297; paper_size_mm_.cy = 297;
custom_gamma_val_->pt_count_r = custom_gamma_val_->pt_count_g = custom_gamma_val_->pt_count_b = 0;
for (int i = 0; i < ARRAY_SIZE(custom_gamma_val_->table); ++i)
custom_gamma_val_->table[i] = i & 0x0ff;
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s(%s) constructed\n", name_.c_str(), hg_log::format_ptr(this).c_str()); VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s(%s) constructed\n", name_.c_str(), hg_log::format_ptr(this).c_str());
image_prc_param_.value = 0; image_prc_param_.value = 0;
@ -2847,17 +2846,22 @@ void hg_scanner::adjust_color(hg_imgproc::HIMGPRC handle)
if (img_conf_.pixtype == COLOR_MODE_BLACK_WHITE || img_conf_.pixtype == COLOR_MODE_256_GRAY) if (img_conf_.pixtype == COLOR_MODE_BLACK_WHITE || img_conf_.pixtype == COLOR_MODE_256_GRAY)
{ {
tableLength = 256; tableLength = 256;
memcpy(buffer1, custom_gamma_val_->table, tableLength); memcpy(buffer1, custom_gamma_val_->table + 256 * GAMMA_INDEX_GRAY, tableLength);
} }
else else
{ {
// convert R[256] + G[256] + B[256] to BGR[256] ... // convert R[256] + G[256] + B[256] to BGR[256] ...
//
// To be modified: here should be color[256] + R[256] + G[256] + B[256] to BGR[256], final pixel = color[R[x]] - commented on 2023-08-07
tableLength = 256 * 3; tableLength = 256 * 3;
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
buffer1[i * 3 + 0] = custom_gamma_val_->table[256 * 2 + i]; //buffer1[i * 3 + 0] = custom_gamma_val_->table[256 * GAMMA_INDEX_BLUE + i];
buffer1[i * 3 + 1] = custom_gamma_val_->table[256 * 1 + i]; //buffer1[i * 3 + 1] = custom_gamma_val_->table[256 * GAMMA_INDEX_GREEN + i];
buffer1[i * 3 + 2] = custom_gamma_val_->table[256 * 0 + i]; //buffer1[i * 3 + 2] = custom_gamma_val_->table[256 * GAMMA_INDEX_RED + i];
buffer1[i * 3 + 0] = custom_gamma_val_->table[256 * GAMMA_INDEX_COLOR + custom_gamma_val_->table[256 * GAMMA_INDEX_BLUE + i]];
buffer1[i * 3 + 1] = custom_gamma_val_->table[256 * GAMMA_INDEX_COLOR + custom_gamma_val_->table[256 * GAMMA_INDEX_GREEN + i]];
buffer1[i * 3 + 2] = custom_gamma_val_->table[256 * GAMMA_INDEX_COLOR + custom_gamma_val_->table[256 * GAMMA_INDEX_RED + i]];
} }
} }
} }