完善文件格式转换及传输方式
This commit is contained in:
parent
0e66d29b90
commit
d8e82950ab
|
@ -72,14 +72,14 @@
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>$(SolutionDir)..\..\code_device\hgdriver\3rdparty\nick;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\opencv\include\win;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\cyusb\inc\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\libtiff\include\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\log4cplus\include\;$(SolutionDir)..\..\code_device\sdk\;$(SolutionDir)..\..\code_device\hgdriver\ImageProcess\;$(SolutionDir)..\..\sdk\include\;$(SolutionDir)..\..\code_device\hgdriver\hgdev\;$(SolutionDir)..\..\code_device\hgdriver\wrapper\;$(ProjectDir);$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\..\code_device\hgdriver\3rdparty\nick;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\opencv\include\win;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\cyusb\inc\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\libtiff\include\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\log4cplus\include\;$(SolutionDir)..\..\code_device\sdk\;$(SolutionDir)..\..\code_device\hgdriver\ImageProcess\;$(SolutionDir)..\..\sdk\include\;$(SolutionDir)..\..\code_device\hgdriver\hgdev\;$(SolutionDir)..\..\code_device\hgdriver\wrapper\;$(ProjectDir);$(SolutionDir)..\..\code_device\hgdriver\3rdparty\tiff\include\;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(ProjectDir)lib\$(PlatformTarget)\$(Configuration);$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(ProjectDir)lib\$(PlatformTarget)\$(Configuration);$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>$(SolutionDir)..\..\code_device\hgdriver\3rdparty\nick;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\opencv\include\win;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\cyusb\inc\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\libtiff\include\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\log4cplus\include\;$(SolutionDir)..\..\code_device\sdk\;$(SolutionDir)..\..\code_device\hgdriver\ImageProcess\;$(SolutionDir)..\..\sdk\include\;$(SolutionDir)..\..\code_device\hgdriver\hgdev\;$(SolutionDir)..\..\code_device\hgdriver\wrapper\;$(ProjectDir);$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\..\code_device\hgdriver\3rdparty\nick;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\opencv\include\win;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\cyusb\inc\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\libtiff\include\;$(SolutionDir)..\..\code_device\hgdriver\3rdparty\log4cplus\include\;$(SolutionDir)..\..\code_device\sdk\;$(SolutionDir)..\..\code_device\hgdriver\ImageProcess\;$(SolutionDir)..\..\sdk\include\;$(SolutionDir)..\..\code_device\hgdriver\hgdev\;$(SolutionDir)..\..\code_device\hgdriver\wrapper\;$(ProjectDir);$(SolutionDir)..\..\code_device\hgdriver\3rdparty\tiff\include\;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(ProjectDir)lib\$(PlatformTarget)\$(Configuration);$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration);$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(ProjectDir)lib\$(PlatformTarget)\$(Configuration);$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||||
|
@ -218,6 +218,7 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$
|
||||||
<ClCompile Include="..\..\code_device\hgdriver\hgdev\PaperSize.cpp" />
|
<ClCompile Include="..\..\code_device\hgdriver\hgdev\PaperSize.cpp" />
|
||||||
<ClCompile Include="..\..\code_device\hgdriver\hgdev\scanner_manager.cpp" />
|
<ClCompile Include="..\..\code_device\hgdriver\hgdev\scanner_manager.cpp" />
|
||||||
<ClCompile Include="..\..\code_device\hgdriver\hgdev\usb_manager.cpp" />
|
<ClCompile Include="..\..\code_device\hgdriver\hgdev\usb_manager.cpp" />
|
||||||
|
<ClCompile Include="..\..\code_device\hgdriver\ImageProcess\G4Tiff.cpp" />
|
||||||
<ClCompile Include="..\..\code_device\hgdriver\ImageProcess\ImageApplySizeDetection.cpp" />
|
<ClCompile Include="..\..\code_device\hgdriver\ImageProcess\ImageApplySizeDetection.cpp" />
|
||||||
<ClCompile Include="..\..\code_device\hgdriver\wrapper\hg_log.cpp" />
|
<ClCompile Include="..\..\code_device\hgdriver\wrapper\hg_log.cpp" />
|
||||||
<ClCompile Include="..\..\code_device\hgdriver\wrapper\huagaoxxx_warraper_ex.cpp" />
|
<ClCompile Include="..\..\code_device\hgdriver\wrapper\huagaoxxx_warraper_ex.cpp" />
|
||||||
|
@ -277,6 +278,7 @@ move /Y "$(OutDirFullPath)$(ProjectName).pdb" "$(SolutionDir)..\..\sdk\lib\win\$
|
||||||
<ClInclude Include="..\..\code_device\hgdriver\hgdev\scanner_manager.h" />
|
<ClInclude Include="..\..\code_device\hgdriver\hgdev\scanner_manager.h" />
|
||||||
<ClInclude Include="..\..\code_device\hgdriver\hgdev\threadpool.h" />
|
<ClInclude Include="..\..\code_device\hgdriver\hgdev\threadpool.h" />
|
||||||
<ClInclude Include="..\..\code_device\hgdriver\hgdev\usb_manager.h" />
|
<ClInclude Include="..\..\code_device\hgdriver\hgdev\usb_manager.h" />
|
||||||
|
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\G4Tiff.h" />
|
||||||
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApply.h" />
|
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApply.h" />
|
||||||
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApplyAdjustColors.h" />
|
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApplyAdjustColors.h" />
|
||||||
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApplyAutoContrast.h" />
|
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\ImageApplyAutoContrast.h" />
|
||||||
|
|
|
@ -180,6 +180,9 @@
|
||||||
<ClCompile Include="..\..\code_device\hgdriver\wrapper\ini_file.cpp">
|
<ClCompile Include="..\..\code_device\hgdriver\wrapper\ini_file.cpp">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\code_device\hgdriver\ImageProcess\G4Tiff.cpp">
|
||||||
|
<Filter>image</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\sdk\hginclude\hg_log.h">
|
<ClInclude Include="..\..\sdk\hginclude\hg_log.h">
|
||||||
|
@ -386,6 +389,9 @@
|
||||||
<ClInclude Include="..\..\code_device\hgdriver\wrapper\ini_file.h">
|
<ClInclude Include="..\..\code_device\hgdriver\wrapper\ini_file.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\code_device\hgdriver\ImageProcess\G4Tiff.h">
|
||||||
|
<Filter>image</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="device.def">
|
<None Include="device.def">
|
||||||
|
|
|
@ -169,6 +169,7 @@ __declspec(novtable) struct ISaneInvoker : public IRef
|
||||||
|
|
||||||
COM_API_DECLARE(bool, get_value(int sn, set_opt_value, void* param));
|
COM_API_DECLARE(bool, get_value(int sn, set_opt_value, void* param));
|
||||||
COM_API_DECLARE(int, set_value(int sn, void* val));
|
COM_API_DECLARE(int, set_value(int sn, void* val));
|
||||||
|
COM_API_DECLARE(int, convert_image(SANE_ImageFormatConvert* conv));
|
||||||
|
|
||||||
// SANE options ID ...
|
// SANE options ID ...
|
||||||
SANE_OPTION_ID_API(is_multiout); // 多流输出
|
SANE_OPTION_ID_API(is_multiout); // 多流输出
|
||||||
|
@ -224,6 +225,7 @@ __declspec(novtable) struct ISaneInvoker : public IRef
|
||||||
SANE_OPTION_ID_API(dogear_size); // 折角检测大小
|
SANE_OPTION_ID_API(dogear_size); // 折角检测大小
|
||||||
SANE_OPTION_ID_API(is_check_skew); // 歪斜检测
|
SANE_OPTION_ID_API(is_check_skew); // 歪斜检测
|
||||||
SANE_OPTION_ID_API(skew_range); // 歪斜容忍度
|
SANE_OPTION_ID_API(skew_range); // 歪斜容忍度
|
||||||
|
SANE_OPTION_ID_API(black_white_threshold); // 二值化图像阈值
|
||||||
|
|
||||||
// SANE-ex option ID:
|
// SANE-ex option ID:
|
||||||
SANE_OPTION_ID_API_EX(multiout_type); // int
|
SANE_OPTION_ID_API_EX(multiout_type); // int
|
||||||
|
|
|
@ -454,6 +454,7 @@ std::string scanned_img::file_header(SANE_ImageType type, float resolution, twai
|
||||||
if (type == SANE_IMAGE_TYPE_BMP && xfer != TWAIN_XFER_Memory)
|
if (type == SANE_IMAGE_TYPE_BMP && xfer != TWAIN_XFER_Memory)
|
||||||
{
|
{
|
||||||
BITMAPINFOHEADER bih = { 0 };
|
BITMAPINFOHEADER bih = { 0 };
|
||||||
|
int pal_size = 0;
|
||||||
|
|
||||||
bih.biSize = sizeof(bih);
|
bih.biSize = sizeof(bih);
|
||||||
bih.biWidth = width();
|
bih.biWidth = width();
|
||||||
|
@ -464,17 +465,37 @@ std::string scanned_img::file_header(SANE_ImageType type, float resolution, twai
|
||||||
bih.biCompression = BI_RGB;
|
bih.biCompression = BI_RGB;
|
||||||
bih.biXPelsPerMeter = bih.biYPelsPerMeter = resolution * 39.37f + .5f;
|
bih.biXPelsPerMeter = bih.biYPelsPerMeter = resolution * 39.37f + .5f;
|
||||||
|
|
||||||
|
if (bih.biBitCount == 1)
|
||||||
|
pal_size = 2 * sizeof(int);
|
||||||
|
else if (bih.biBitCount == 8)
|
||||||
|
pal_size = 256 * sizeof(int);
|
||||||
|
|
||||||
if (xfer == TWAIN_XFER_File)
|
if (xfer == TWAIN_XFER_File)
|
||||||
{
|
{
|
||||||
BITMAPFILEHEADER fh = { 0 };
|
BITMAPFILEHEADER fh = { 0 };
|
||||||
fh.bfType = MAKEWORD('B', 'M');
|
fh.bfType = MAKEWORD('B', 'M');
|
||||||
fh.bfSize = sizeof(fh) + bih.biSizeImage + sizeof(bih);
|
fh.bfSize = sizeof(fh) + bih.biSizeImage + sizeof(bih);
|
||||||
fh.bfOffBits = sizeof(fh) + sizeof(bih);
|
fh.bfOffBits = sizeof(fh) + sizeof(bih) + pal_size;
|
||||||
|
|
||||||
h = std::string((char*)&fh, sizeof(fh));
|
h = std::string((char*)&fh, sizeof(fh));
|
||||||
}
|
}
|
||||||
|
|
||||||
h += std::string((char*)&bih, sizeof(bih));
|
h += std::string((char*)&bih, sizeof(bih));
|
||||||
|
if (bih.biBitCount == 1)
|
||||||
|
{
|
||||||
|
int pal[] = { 0, 0x0ffffff };
|
||||||
|
h += std::string((char*)pal, pal_size);
|
||||||
|
}
|
||||||
|
else if (bih.biBitCount == 8)
|
||||||
|
{
|
||||||
|
static unsigned int g_bmp8_pallete[256] = { 0 };
|
||||||
|
if (g_bmp8_pallete[1] == 0)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < _countof(g_bmp8_pallete); ++i)
|
||||||
|
g_bmp8_pallete[i] = MAKELONG(MAKEWORD(i, i), MAKEWORD(i, 0));
|
||||||
|
}
|
||||||
|
h += std::string((char*)g_bmp8_pallete, pal_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
|
|
|
@ -323,6 +323,7 @@ int scanner::init_options_id(void)
|
||||||
else SET_OPT_ID(dogear_size, ZJDX, extension_none)
|
else SET_OPT_ID(dogear_size, ZJDX, extension_none)
|
||||||
else SET_OPT_ID(is_check_skew, WXJC, extension_none)
|
else SET_OPT_ID(is_check_skew, WXJC, extension_none)
|
||||||
else SET_OPT_ID(skew_range, WXRRD, extension_none)
|
else SET_OPT_ID(skew_range, WXRRD, extension_none)
|
||||||
|
else SET_OPT_ID(black_white_threshold, HBTXYZ, extension_none)
|
||||||
op_id++;
|
op_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,6 +344,9 @@ int scanner::init_options_id(void)
|
||||||
EX_APPENDIX_API(hardware_version);
|
EX_APPENDIX_API(hardware_version);
|
||||||
EX_APPENDIX_API(ip);
|
EX_APPENDIX_API(ip);
|
||||||
|
|
||||||
|
if (black_white_threshold_id_ == -1)
|
||||||
|
black_white_threshold_id_ = 0x8836;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
int scanner::control_read_string(int code, std::string& ret)
|
int scanner::control_read_string(int code, std::string& ret)
|
||||||
|
@ -1771,6 +1775,11 @@ COM_API_IMPLEMENT(scanner, int, set_value(int sn, void* val))
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
COM_API_IMPLEMENT(scanner, int, convert_image(SANE_ImageFormatConvert* conv))
|
||||||
|
{
|
||||||
|
return hg_sane_middleware::instance()->io_control(handle_, IO_CTRL_CODE_CONVERT_IMAGE_FORMAT, conv, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// SANE options ID ...
|
// SANE options ID ...
|
||||||
SANE_OPTION_ID_IMPLEMENT(is_multiout)
|
SANE_OPTION_ID_IMPLEMENT(is_multiout)
|
||||||
|
@ -1826,6 +1835,7 @@ SANE_OPTION_ID_IMPLEMENT(is_check_dogear)
|
||||||
SANE_OPTION_ID_IMPLEMENT(dogear_size)
|
SANE_OPTION_ID_IMPLEMENT(dogear_size)
|
||||||
SANE_OPTION_ID_IMPLEMENT(is_check_skew)
|
SANE_OPTION_ID_IMPLEMENT(is_check_skew)
|
||||||
SANE_OPTION_ID_IMPLEMENT(skew_range)
|
SANE_OPTION_ID_IMPLEMENT(skew_range)
|
||||||
|
SANE_OPTION_ID_IMPLEMENT(black_white_threshold)
|
||||||
|
|
||||||
// SANE-ex option ID:
|
// SANE-ex option ID:
|
||||||
SANE_OPTION_ID_IMPLEMENT(ex_multiout_type)
|
SANE_OPTION_ID_IMPLEMENT(ex_multiout_type)
|
||||||
|
|
|
@ -197,6 +197,7 @@ public:
|
||||||
COM_API_OVERRIDE(bool, get_option_info(int sn, value_type* type, value_limit* limit, int* bytes));
|
COM_API_OVERRIDE(bool, get_option_info(int sn, value_type* type, value_limit* limit, int* bytes));
|
||||||
COM_API_OVERRIDE(bool, get_value(int sn, set_opt_value, void* param));
|
COM_API_OVERRIDE(bool, get_value(int sn, set_opt_value, void* param));
|
||||||
COM_API_OVERRIDE(int, set_value(int sn, void* val));
|
COM_API_OVERRIDE(int, set_value(int sn, void* val));
|
||||||
|
COM_API_OVERRIDE(int, convert_image(SANE_ImageFormatConvert* conv));
|
||||||
|
|
||||||
// SANE options ID ...
|
// SANE options ID ...
|
||||||
SANE_OPTION_ID(is_multiout);
|
SANE_OPTION_ID(is_multiout);
|
||||||
|
@ -252,6 +253,7 @@ public:
|
||||||
SANE_OPTION_ID(dogear_size);
|
SANE_OPTION_ID(dogear_size);
|
||||||
SANE_OPTION_ID(is_check_skew);
|
SANE_OPTION_ID(is_check_skew);
|
||||||
SANE_OPTION_ID(skew_range);
|
SANE_OPTION_ID(skew_range);
|
||||||
|
SANE_OPTION_ID(black_white_threshold); // 二值化图像阈值
|
||||||
|
|
||||||
// SANE-ex option ID:
|
// SANE-ex option ID:
|
||||||
SANE_OPTION_ID(ex_multiout_type); // int
|
SANE_OPTION_ID(ex_multiout_type); // int
|
||||||
|
|
|
@ -48,12 +48,14 @@
|
||||||
<IncludePath>$(SolutionDir)..\..\sdk\include\;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\..\sdk\include\;$(IncludePath)</IncludePath>
|
||||||
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>$(SolutionDir)..\..\sdk\include\;$(IncludePath)</IncludePath>
|
<IncludePath>$(SolutionDir)..\..\sdk\include\;$(IncludePath)</IncludePath>
|
||||||
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
<OutDir>$(SolutionDir)..\..\release\win\$(PlatformTarget)\$(Configuration)\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
<IntDir>$(SolutionDir)..\..\tmp\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
<LibraryPath>$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -64,11 +66,14 @@
|
||||||
<SDLCheck>true</SDLCheck>
|
<SDLCheck>true</SDLCheck>
|
||||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<ModuleDefinitionFile>$(ProjectDir)twain.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>$(ProjectDir)twain.def</ModuleDefinitionFile>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>mkdir $(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
|
<Command>mkdir $(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
|
||||||
|
@ -96,6 +101,8 @@ copy $(TargetPath) $(WinDir)\twain_32\HuaGoScan\huagaotwain.ds /y</Command>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<ModuleDefinitionFile>$(ProjectDir)twain.def</ModuleDefinitionFile>
|
<ModuleDefinitionFile>$(ProjectDir)twain.def</ModuleDefinitionFile>
|
||||||
|
<AdditionalDependencies>
|
||||||
|
</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>mkdir $(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
|
<Command>mkdir $(SolutionDir)..\..\sdk\lib\win\$(PlatformTarget)\$(Configuration)
|
||||||
|
@ -107,6 +114,7 @@ copy $(TargetPath) $(WinDir)\twain_32\HuaGoScan\$(ProjectName).ds /y</Command>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\sane\s2t_api.h" />
|
<ClInclude Include="..\sane\s2t_api.h" />
|
||||||
|
<ClInclude Include="brand.h" />
|
||||||
<ClInclude Include="load_sane.h" />
|
<ClInclude Include="load_sane.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
|
|
|
@ -171,6 +171,9 @@
|
||||||
<ClInclude Include="load_sane.h">
|
<ClInclude Include="load_sane.h">
|
||||||
<Filter>Headers</Filter>
|
<Filter>Headers</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="brand.h">
|
||||||
|
<Filter>Headers</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="huagaotwain.rc">
|
<ResourceCompile Include="huagaotwain.rc">
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#define mktemp _mktemp
|
#define mktemp _mktemp
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define enum2str(R) #R
|
#define enum2str(R) #R
|
||||||
|
@ -121,6 +122,7 @@ enum CapTypeEx : unsigned short {
|
||||||
CAP_EX_SANE_dogear_size,
|
CAP_EX_SANE_dogear_size,
|
||||||
CAP_EX_SANE_is_check_skew,
|
CAP_EX_SANE_is_check_skew,
|
||||||
CAP_EX_SANE_skew_range,
|
CAP_EX_SANE_skew_range,
|
||||||
|
CAP_EX_SANE_black_white_threshold,
|
||||||
// END for SANE设备层原始设置项透传属性
|
// END for SANE设备层原始设置项透传属性
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
};
|
};
|
||||||
|
@ -570,19 +572,7 @@ float trans_range(float val, float min_from, float max_from, float min_to, float
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// huagao_ds ...
|
// huagao_ds ...
|
||||||
#define PRODUCT_PID 0x0100
|
#include "../brand.h"
|
||||||
#define PRODUCT_VID 0x3072
|
|
||||||
#define PRODUCT_VENDOR "HUAGO"
|
|
||||||
#define PRODUCT_FAMILY "HG100"
|
|
||||||
#define PRODUCT_NAME "HG0100"
|
|
||||||
|
|
||||||
#define TO_STR(a) #a
|
|
||||||
#define VERSION_MAIN 4
|
|
||||||
#define VERSION_SUB 1007
|
|
||||||
#define VERSION_BUILD 2022
|
|
||||||
#define VERSION_PATCH 6131
|
|
||||||
#define TO_VER_STR(vs) TO_STR(v##vs)
|
|
||||||
#define VERSION_STR(a, b, c, d) TO_VER_STR(a.b.c.d)
|
|
||||||
|
|
||||||
static Identity* srcIdent = new Identity(
|
static Identity* srcIdent = new Identity(
|
||||||
Version(VERSION_MAIN, VERSION_SUB, Language::English, Country::China, VERSION_STR(VERSION_MAIN, VERSION_SUB, VERSION_BUILD, VERSION_PATCH)),
|
Version(VERSION_MAIN, VERSION_SUB, Language::English, Country::China, VERSION_STR(VERSION_MAIN, VERSION_SUB, VERSION_BUILD, VERSION_PATCH)),
|
||||||
|
@ -876,7 +866,7 @@ Result huagao_ds::imageInfoGet(const Identity&, ImageInfo& data)
|
||||||
GET_SANE_OPT(int, scanner_, resolution, &res, NULL, NULL, NULL, NULL);
|
GET_SANE_OPT(int, scanner_, resolution, &res, NULL, NULL, NULL, NULL);
|
||||||
data.setXResolution(res);
|
data.setXResolution(res);
|
||||||
data.setYResolution(res);
|
data.setYResolution(res);
|
||||||
data.compression(Compression::None);
|
data.compression(m_compression);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
|
@ -1054,6 +1044,30 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
|
||||||
else
|
else
|
||||||
DeleteFileA(file.c_str());
|
DeleteFileA(file.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret.status() == ConditionCode::Success && m_fileXfer.format() != ImageFileFormat::Bmp)
|
||||||
|
{
|
||||||
|
SANE_ImageFormatConvert conv;
|
||||||
|
std::string target(m_fileXfer.filePath().string().c_str());
|
||||||
|
|
||||||
|
file = target + ".src";
|
||||||
|
conv.src.fmt.img_format = SANE_IMAGE_TYPE_BMP;
|
||||||
|
conv.src.is_file = SANE_TRUE;
|
||||||
|
conv.src.data = file.c_str();
|
||||||
|
conv.src.data_len = file.length();
|
||||||
|
|
||||||
|
conv.dst.fmt.img_format = (SANE_ImageType)m_fileXfer.format();
|
||||||
|
conv.dst.fmt.compress.compression = (SANE_CompressionType)m_compression;
|
||||||
|
conv.dst.fmt.compress.detail = (void*)0;
|
||||||
|
conv.dst.fmt.detail = (void*)m_jpegQuality;
|
||||||
|
conv.dst.is_file = SANE_TRUE;
|
||||||
|
conv.dst.data = target.c_str();
|
||||||
|
conv.dst.data_len = target.length();
|
||||||
|
MoveFileA(target.c_str(), file.c_str());
|
||||||
|
if(scanner_->convert_image(&conv) != SANE_STATUS_GOOD)
|
||||||
|
ret = { ReturnCode::Failure, ConditionCode::FileWriteError };
|
||||||
|
DeleteFileA(file.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1215,30 +1229,40 @@ void huagao_ds::init_support_caps(void)
|
||||||
m_caps[CapType::ICompression] = [this](Msg msg, Capability& data)->Result {
|
m_caps[CapType::ICompression] = [this](Msg msg, Capability& data)->Result {
|
||||||
if (!scanner_.get())
|
if (!scanner_.get())
|
||||||
return seqError();
|
return seqError();
|
||||||
if (msg == Msg::Set || msg == Msg::Reset)
|
if (Msg::Set == msg) {
|
||||||
{
|
auto mech = data.currentItem<CapType::ICompression>();
|
||||||
int mech = (int)data.currentItem<CapType::ICompression>();
|
if (Compression::None == mech || mech == Compression::Group4) {
|
||||||
if (msg == Msg::Reset)
|
m_compression = mech;
|
||||||
GET_SANE_OPT(int, scanner_, ex_final_compression, NULL, &mech, NULL, NULL);
|
return success();
|
||||||
|
}
|
||||||
int ret = SCANNER_ERR_OK;
|
else
|
||||||
SET_SANE_OPT(ret, scanner_, ex_final_compression, (int*)&mech);
|
return badValue();
|
||||||
return ret == SCANNER_ERR_OK ? success() : badValue();
|
|
||||||
}
|
}
|
||||||
std::vector<int> values;
|
return CapSupGetAllReset<Compression, Compression, CapType::ICompression>(msg, data, { Compression::None, Compression::Group4 }, m_compression, Compression::None, m_compression == Compression::None ? 0 : 1, 0);
|
||||||
int init = 0, now = 0;
|
//if (msg == Msg::Set || msg == Msg::Reset)
|
||||||
std::list<Compression> vals;
|
//{
|
||||||
Compression Now, Init;
|
// int mech = (int)data.currentItem<CapType::ICompression>();
|
||||||
UInt32 ni = 0, ii = 0;
|
// if (msg == Msg::Reset)
|
||||||
|
// GET_SANE_OPT(int, scanner_, ex_final_compression, NULL, &mech, NULL, NULL);
|
||||||
|
|
||||||
GET_SANE_OPT(int, scanner_, ex_final_compression, &now, &init, &values, NULL);
|
// int ret = SCANNER_ERR_OK;
|
||||||
Now = (Compression)now;
|
// SET_SANE_OPT(ret, scanner_, ex_final_compression, (int*)&mech);
|
||||||
Init = (Compression)init;
|
// return ret == SCANNER_ERR_OK ? success() : badValue();
|
||||||
for (const auto& v : values)
|
//}
|
||||||
vals.push_back((Compression)v);
|
//std::vector<int> values;
|
||||||
ni = std::distance(values.begin(), std::find(values.begin(), values.end(), now));
|
//int init = 0, now = 0;
|
||||||
ii = std::distance(values.begin(), std::find(values.begin(), values.end(), init));
|
//std::list<Compression> vals;
|
||||||
return cap_get_enum_values<Compression, CapType::ICompression>(msg, data, vals, Now, Init, ni, ii);
|
//Compression Now, Init;
|
||||||
|
//UInt32 ni = 0, ii = 0;
|
||||||
|
|
||||||
|
//GET_SANE_OPT(int, scanner_, ex_final_compression, &now, &init, &values, NULL);
|
||||||
|
//Now = (Compression)now;
|
||||||
|
//Init = (Compression)init;
|
||||||
|
//for (const auto& v : values)
|
||||||
|
// vals.push_back((Compression)v);
|
||||||
|
//ni = std::distance(values.begin(), std::find(values.begin(), values.end(), now));
|
||||||
|
//ii = std::distance(values.begin(), std::find(values.begin(), values.end(), init));
|
||||||
|
//return cap_get_enum_values<Compression, CapType::ICompression>(msg, data, vals, Now, Init, ni, ii);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_query[CapType::IUnits] = msgSupportGetAllSetReset;
|
m_query[CapType::IUnits] = msgSupportGetAllSetReset;
|
||||||
|
@ -1518,16 +1542,20 @@ void huagao_ds::init_support_caps(void)
|
||||||
if ((int)mech <= 0 || (int)mech > 100)
|
if ((int)mech <= 0 || (int)mech > 100)
|
||||||
return badValue();
|
return badValue();
|
||||||
|
|
||||||
int ret = SCANNER_ERR_OK;
|
m_jpegQuality = (int)mech;
|
||||||
fif.detail = (void*)mech;
|
return success();
|
||||||
SET_SANE_OPT(ret, scanner_, ex_final_format, &fif);
|
//int ret = SCANNER_ERR_OK;
|
||||||
return ret == SCANNER_ERR_OK ? success() : badValue();
|
//fif.detail = (void*)mech;
|
||||||
|
//SET_SANE_OPT(ret, scanner_, ex_final_format, &fif);
|
||||||
|
//return ret == SCANNER_ERR_OK ? success() : badValue();
|
||||||
}
|
}
|
||||||
unsigned short q = 80;
|
//unsigned short q = 80;
|
||||||
fif.detail = (void*)q;
|
//fif.detail = (void*)q;
|
||||||
GET_SANE_OPT(SANE_FinalImgFormat, scanner_, ex_final_format, &fif, NULL, NULL, NULL);
|
//GET_SANE_OPT(SANE_FinalImgFormat, scanner_, ex_final_format, &fif, NULL, NULL, NULL);
|
||||||
if(fif.img_format == SANE_IMAGE_TYPE_JPG)
|
//if(fif.img_format == SANE_IMAGE_TYPE_JPG)
|
||||||
q = (unsigned short)fif.detail;
|
// q = (unsigned short)fif.detail;
|
||||||
|
//return CapSupGetAllResetEx<unsigned short, UInt16, CapType::IJpegQuality>(msg, data, q, 80);
|
||||||
|
unsigned short q = m_jpegQuality;
|
||||||
return CapSupGetAllResetEx<unsigned short, UInt16, CapType::IJpegQuality>(msg, data, q, 80);
|
return CapSupGetAllResetEx<unsigned short, UInt16, CapType::IJpegQuality>(msg, data, q, 80);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1621,13 +1649,20 @@ void huagao_ds::init_support_caps(void)
|
||||||
std::vector<SANE_FinalImgFormat> all;
|
std::vector<SANE_FinalImgFormat> all;
|
||||||
GET_SANE_OPT(SANE_FinalImgFormat, scanner_, ex_final_format, &now, &init, &all, NULL);
|
GET_SANE_OPT(SANE_FinalImgFormat, scanner_, ex_final_format, &now, &init, &all, NULL);
|
||||||
if (Msg::Set == msg || Msg::Reset == msg) {
|
if (Msg::Set == msg || Msg::Reset == msg) {
|
||||||
if(Msg::Set == msg)
|
auto fmt = data.currentItem<ImageFileFormat>();
|
||||||
init.img_format = (SANE_ImageType)(int)data.currentItem<ImageFileFormat>();
|
if (fmt != Twpp::ImageFileFormat::Bmp &&
|
||||||
int ret = SCANNER_ERR_OK;
|
fmt != Twpp::ImageFileFormat::Jfif &&
|
||||||
SET_SANE_OPT(ret, scanner_, ex_final_format, &init);
|
fmt != Twpp::ImageFileFormat::Tiff)
|
||||||
return ret == SCANNER_ERR_OK ? success() : badValue();
|
return badValue();
|
||||||
|
m_fileXfer.setFormat((Twpp::ImageFileFormat)data.currentItem<ImageFileFormat>());
|
||||||
|
return success();
|
||||||
|
//if(Msg::Set == msg)
|
||||||
|
// init.img_format = (SANE_ImageType)(int)data.currentItem<ImageFileFormat>();
|
||||||
|
//int ret = SCANNER_ERR_OK;
|
||||||
|
//SET_SANE_OPT(ret, scanner_, ex_final_format, &init);
|
||||||
|
//return ret == SCANNER_ERR_OK ? success() : badValue();
|
||||||
}
|
}
|
||||||
ImageFileFormat Now = (ImageFileFormat)(int)now.img_format, Init = (ImageFileFormat)(int)init.img_format;
|
ImageFileFormat Now = m_fileXfer.format(), Init = (ImageFileFormat)(int)init.img_format;
|
||||||
std::list<ImageFileFormat> vals;
|
std::list<ImageFileFormat> vals;
|
||||||
UInt32 i = 0, n = 0;
|
UInt32 i = 0, n = 0;
|
||||||
for (const auto& v : all)
|
for (const auto& v : all)
|
||||||
|
@ -2464,6 +2499,7 @@ void huagao_ds::init_support_caps_ex(void)
|
||||||
ADD_SANE_CAP(dogear_size);
|
ADD_SANE_CAP(dogear_size);
|
||||||
ADD_SANE_CAP(is_check_skew);
|
ADD_SANE_CAP(is_check_skew);
|
||||||
ADD_SANE_CAP(skew_range);
|
ADD_SANE_CAP(skew_range);
|
||||||
|
ADD_SANE_CAP(black_white_threshold);
|
||||||
}
|
}
|
||||||
void huagao_ds::on_scan_event(int sane_event, void* data, unsigned int* len)
|
void huagao_ds::on_scan_event(int sane_event, void* data, unsigned int* len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,8 @@ class huagao_ds : public Twpp::SourceFromThis<huagao_ds> {
|
||||||
int automaticcolortype_ = 0;
|
int automaticcolortype_ = 0;
|
||||||
bool multi_out_ = false;
|
bool multi_out_ = false;
|
||||||
bool m_bIndicator = true;
|
bool m_bIndicator = true;
|
||||||
|
int m_jpegQuality = 80;
|
||||||
|
Twpp::Compression m_compression = Twpp::Compression::None;
|
||||||
|
|
||||||
static std::string get_hidedlg_path(void);
|
static std::string get_hidedlg_path(void);
|
||||||
static void showmsg(const char* msg, int err);
|
static void showmsg(const char* msg, int err);
|
||||||
|
|
Loading…
Reference in New Issue