穿孔移除分解为四个方位;增加黑白图像反色输出属性
This commit is contained in:
parent
d6a82ec85b
commit
0330c49739
|
@ -14,7 +14,7 @@ static int ui_default_callback(scanner_handle, int, void*, unsigned int*, void*)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
static std::string bmp_821(unsigned char* bits/*bits data*/, int w, int h, int* lbytes, bool line_align_4, int threashold)
|
||||
static std::string bmp_821(unsigned char* bits/*bits data*/, int w, int h, int* lbytes, bool line_align_4, int threashold, bool reverse)
|
||||
{
|
||||
static unsigned int g_bmp8_pallete[] = {
|
||||
0x00000000, 0x00800000, 0x00008000, 0x00808000, 0x00000080, 0x00800080, 0x00008080, 0x00c0c0c0, 0x00c0dcc0, 0x00a6caf0, 0x00402000, 0x00602000, 0x00802000, 0x00a02000, 0x00c02000, 0x00e02000
|
||||
|
@ -38,14 +38,13 @@ static std::string bmp_821(unsigned char* bits/*bits data*/, int w, int h, int*
|
|||
size = l * h,
|
||||
line_bytes = (w + 3) / 4 * 4;
|
||||
std::string f("");
|
||||
unsigned char* data = nullptr, mask = 0;
|
||||
unsigned char* data = nullptr, mask = reverse ? -1 : 0;
|
||||
unsigned int* pallete = g_bmp8_pallete;
|
||||
|
||||
if (!line_align_4)
|
||||
{
|
||||
l = (w + 7) / 8;
|
||||
size = l * h;
|
||||
mask = -1;
|
||||
}
|
||||
if (lbytes && *lbytes)
|
||||
line_bytes = *lbytes;
|
||||
|
@ -97,6 +96,7 @@ hg_scanner::hg_scanner(ScannerSerial serial
|
|||
, setting_count_(0),img_type_(""), online_(false),is_quality_(-1),is_color_fill(false),is_multiout(false),save_multiout(OPTION_VALUE_DLSCLX_CS_HD_HB)
|
||||
, final_img_index_(0), custom_area_(false),save_sizecheck(false), bw_threshold_(128), custom_gamma_(false)
|
||||
, double_paper_handle_(0), keep_watermark_(false), save_feedmode_type_(false), feedmode_(1), sleeptime_(-1),split3399_(0)
|
||||
, async_io_(false), is_white_0_(true)
|
||||
{
|
||||
final_path_ = hg_log::ini_get("paths", "final_img");
|
||||
if(final_path_.empty())
|
||||
|
@ -287,10 +287,10 @@ void hg_scanner::set_setting_map(int sn, const char* title)
|
|||
setting_map_[sn] = &hg_scanner::setting_split_image;
|
||||
else if (val == OPTION_TITLE_ZDJP)
|
||||
setting_map_[sn] = &hg_scanner::setting_automatic_skew;
|
||||
else if (val == OPTION_TITLE_CKYC)
|
||||
setting_map_[sn] = &hg_scanner::setting_rid_hole;
|
||||
else if (val == OPTION_TITLE_CKSSFWZFMBL)
|
||||
setting_map_[sn] = &hg_scanner::setting_rid_hoe_range;
|
||||
//else if (val == OPTION_TITLE_CKYC)
|
||||
// setting_map_[sn] = &hg_scanner::setting_rid_hole;
|
||||
//else if (val == OPTION_TITLE_CKSSFWZFMBL)
|
||||
// setting_map_[sn] = &hg_scanner::setting_rid_hoe_range;
|
||||
else if (val == OPTION_TITLE_QYSDQX)
|
||||
setting_map_[sn] = &hg_scanner::setting_is_custom_gamma;
|
||||
else if (val == OPTION_TITLE_LDZ)
|
||||
|
@ -355,6 +355,8 @@ void hg_scanner::set_setting_map(int sn, const char* title)
|
|||
setting_map_[sn] = &hg_scanner::setting_color_fill;
|
||||
else if(val == OPTION_TITLE_HBTXYZ)
|
||||
setting_map_[sn] = &hg_scanner::setting_black_white_threshold;
|
||||
else if(val == OPTION_TITLE_HBTXFSSC)
|
||||
setting_map_[sn] = &hg_scanner::setting_white_pixel_0;
|
||||
else if(val == OPTION_TITLE_ZPMS)
|
||||
setting_map_[sn] = &hg_scanner::setting_keep_watermark;
|
||||
else if (val == OPTION_TITLE_XMSJ)
|
||||
|
@ -1717,6 +1719,12 @@ int hg_scanner::setting_black_white_threshold(int sn, void* data)
|
|||
|
||||
return SCANNER_ERR_OK;
|
||||
}
|
||||
int hg_scanner::setting_white_pixel_0(int sn, void* data)
|
||||
{
|
||||
is_white_0_ = *(bool*)data;
|
||||
|
||||
return SCANNER_ERR_OK;
|
||||
}
|
||||
int hg_scanner::setting_setfeedmode(int sn, void* data)
|
||||
{
|
||||
std::string str((char *)data);
|
||||
|
@ -2027,7 +2035,14 @@ void hg_scanner::init_settings(const char* json_setting_text)
|
|||
}
|
||||
else if (val == "bool")
|
||||
{
|
||||
std::string name(""); // is_white_0_
|
||||
bool v = false;
|
||||
setting_jsn_.at(key).at("name").get_to(name);
|
||||
if (name == SANE_STD_OPT_NAME_REVERSE_01)
|
||||
{
|
||||
setting_jsn_.at(key).at("default") = is_white_0_;
|
||||
setting_jsn_.at(key).at("cur") = is_white_0_;
|
||||
}
|
||||
setting_jsn_.at(key).at("default").get_to(v);
|
||||
set_setting(sn, (char*)&v, sizeof(v));
|
||||
}
|
||||
|
@ -2251,7 +2266,7 @@ int hg_scanner::save_final_image(hg_imgproc::LPIMGHEAD head, void* buf)
|
|||
if (img_conf_.pixtype == 0 || (is_1bit && is_multiout))
|
||||
{
|
||||
int old = head->line_bytes;
|
||||
bw = bmp_821((unsigned char*)buf, head->width, head->height, &head->line_bytes, async_io_, bw_threshold_);
|
||||
bw = bmp_821((unsigned char*)buf, head->width, head->height, &head->line_bytes, async_io_, bw_threshold_, is_white_0_);
|
||||
buf = &bw[0];
|
||||
head->channels = head->bits = 1;
|
||||
head->total_bytes = head->line_bytes * head->height;
|
||||
|
@ -2331,6 +2346,7 @@ void hg_scanner::set_ui_callback(sane_callback cb, bool enable_async_io)
|
|||
{
|
||||
ui_ev_cb_ = cb ? cb : ui_default_callback;
|
||||
async_io_ = enable_async_io;
|
||||
is_white_0_ = !async_io_;
|
||||
}
|
||||
int hg_scanner::get_pid(void)
|
||||
{
|
||||
|
|
|
@ -152,6 +152,7 @@ protected:
|
|||
int setting_color_fill(int sn, void*data);
|
||||
int setting_keep_watermark(int sn, void* data);
|
||||
int setting_black_white_threshold(int sn, void* data);
|
||||
int setting_white_pixel_0(int sn, void* data);
|
||||
int setting_setfeedmode(int sn, void* data);
|
||||
int setting_setsleeptime(int sn, void* data);
|
||||
int setting_set_auto_pick_paper(int sn, void* data);
|
||||
|
@ -280,6 +281,9 @@ protected:
|
|||
int double_paper_handle_; // 汉王要求出现双张的时候可保留
|
||||
bool keep_watermark_; // 汉王要求图像处理过程中保留水印 - 是否与背景移除、背景填充相关???
|
||||
|
||||
// 2022-08-31 新增黑白图像是否反色输出(PNM黑白像素与BMP黑白像素相反)
|
||||
bool is_white_0_; // 是否‘0’代表白色
|
||||
|
||||
public:
|
||||
void set_ui_callback(sane_callback cb, bool enable_async_io);
|
||||
int reset_io(usb_io* io);
|
||||
|
|
Loading…
Reference in New Issue