Merge branch 'master' of http://192.168.100.140:8099/sane/code_app
This commit is contained in:
commit
33c2c40d04
|
@ -77,7 +77,13 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
#endif
|
||||
this->setAutoFillBackground(true);
|
||||
this->setPalette(QPalette(QColor(230, 230, 230)));
|
||||
|
||||
QDesktopWidget *desktopWidget = QApplication::desktop();
|
||||
QRect screenRect = desktopWidget->screenGeometry(this);
|
||||
if(screenRect.width() > 950 || screenRect.height() > 720)
|
||||
{
|
||||
resize(950, 720);
|
||||
}
|
||||
|
||||
m_config.load();
|
||||
|
||||
|
@ -2480,7 +2486,13 @@ void MainWindow::on_act_help_triggered()
|
|||
QString filename = "/opt/apps/scanner-driver-huagao/doc/HuaGoScan_App_Help_manual.pdf";
|
||||
#endif
|
||||
#else
|
||||
QString filename = nullptr;
|
||||
#if defined(OEM_HANWANG)
|
||||
QString filename = "/opt/apps/scanner-driver-hanvon/doc/HanvonScan_App_Help_manual.pdf";
|
||||
#elif defined(OEM_LISICHENG)
|
||||
QString filename = "/opt/apps/scanner-driver-lanxum/doc/LanxumScan_App_Help_manual.pdf";
|
||||
#else
|
||||
QString filename = "/opt/apps/scanner-driver-huagao/doc/HuaGoScan_App_Help_manual.pdf";
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -110,6 +110,34 @@ unix {
|
|||
|
||||
}
|
||||
}
|
||||
}else{
|
||||
contains(ARCH, x86_64){
|
||||
LIBS += -L../../../release/kylin/x86_64 -lHGBase -lHGImgFmt -lHGImgProc -lsane-hgsane -lhgdriver
|
||||
CONFIG(release, debug|release) {
|
||||
DESTDIR = ../../../release/kylin/x86_64/
|
||||
}
|
||||
CONFIG(debug, debug|release) {
|
||||
|
||||
}
|
||||
}
|
||||
contains(ARCH, aarch64){
|
||||
LIBS += -L../../../release/kylin/aarch64 -lHGBase -lHGImgFmt -lHGImgProc -lsane-hgsane -lhgdriver
|
||||
CONFIG(release, debug|release) {
|
||||
DESTDIR = ../../../release/kylin/aarch64/
|
||||
}
|
||||
CONFIG(debug, debug|release) {
|
||||
|
||||
}
|
||||
}
|
||||
contains(ARCH, mips64){
|
||||
LIBS += -L../../../release/kylin/mips64 -lHGBase -lHGImgFmt -lHGImgProc -lsane-hgsane -lhgdriver
|
||||
CONFIG(release, debug|release) {
|
||||
DESTDIR = ../../../release/kylin/mips64/
|
||||
}
|
||||
CONFIG(debug, debug|release) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
7
build.sh
7
build.sh
|
@ -70,13 +70,6 @@ rm -rf ./obj
|
|||
rm -f makefile
|
||||
rm HGImgProcTmp.cbp
|
||||
|
||||
#cd ../HGWebService
|
||||
#cbp2make -targets ${system}_${arch}_Release -in HGWebService.cbp -out makefile
|
||||
#make -j6
|
||||
#rm -rf ./bin
|
||||
#rm -rf ./obj
|
||||
#rm -f makefile
|
||||
|
||||
cd ../../../build-qt/HGSolution
|
||||
cp HGScanner.pro HGScannerTmp.pro
|
||||
if [ "${1}" == "hw" ]; then
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/uos/amd64/include" />
|
||||
<Add directory="../../../third_party/freetype/uos/amd64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -26,6 +27,8 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/uos/amd64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../HGBase/bin/uos_x86_64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/uos_x86_64_Debug -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
|
@ -42,6 +45,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/uos/amd64/include" />
|
||||
<Add directory="../../../third_party/freetype/uos/amd64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -53,6 +57,8 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/uos/amd64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../../../../release/uos/x86_64 -lHGBase -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
<Add option="-lpthread" />
|
||||
|
@ -68,6 +74,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/uos/aarch64/include" />
|
||||
<Add directory="../../../third_party/freetype/uos/aarch64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -78,6 +85,8 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/uos/aarch64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../HGBase/bin/uos_aarch64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/uos_aarch64_Debug -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
|
@ -94,6 +103,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/uos/aarch64/include" />
|
||||
<Add directory="../../../third_party/freetype/uos/aarch64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -105,6 +115,8 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/uos/aarch64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../../../../release/uos/aarch64 -lHGBase -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
<Add option="-lpthread" />
|
||||
|
@ -120,6 +132,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/uos/mips64/include" />
|
||||
<Add directory="../../../third_party/freetype/uos/mips64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -129,6 +142,8 @@
|
|||
<Add option="-lopencv_imgproc" />
|
||||
<Add option="-lopencv_core" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/uos/mips64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../HGBase/bin/uos_mips64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/uos_mips64_Debug -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
|
@ -145,6 +160,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/uos/mips64/include" />
|
||||
<Add directory="../../../third_party/freetype/uos/mips64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/uos/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -155,6 +171,8 @@
|
|||
<Add option="-lopencv_imgproc" />
|
||||
<Add option="-lopencv_core" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/uos/mips64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../../../../release/uos/mips64 -lHGBase -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
<Add option="-lpthread" />
|
||||
|
@ -170,6 +188,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/kylin/amd64/include" />
|
||||
<Add directory="../../../third_party/freetype/kylin/amd64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/kylin/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -180,6 +199,8 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/kylin/amd64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../HGBase/bin/kylin_x86_64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/kylin_x86_64_Debug -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
|
@ -196,6 +217,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/kylin/amd64/include" />
|
||||
<Add directory="../../../third_party/freetype/kylin/amd64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/kylin/amd64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -207,6 +229,8 @@
|
|||
<Add option="-lopencv_core" />
|
||||
<Add option="-littnotify" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/kylin/amd64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../../../../release/kylin/x86_64 -lHGBase -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
<Add option="-lpthread" />
|
||||
|
@ -222,6 +246,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/kylin/aarch64/include" />
|
||||
<Add directory="../../../third_party/freetype/kylin/aarch64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/kylin/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -233,6 +258,8 @@
|
|||
<Add option="-littnotify" />
|
||||
<Add option="-ltegra_hal" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/kylin/aarch64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../HGBase/bin/kylin_aarch64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/kylin_aarch64_Debug -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
|
@ -249,6 +276,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/kylin/aarch64/include" />
|
||||
<Add directory="../../../third_party/freetype/kylin/aarch64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/kylin/aarch64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -261,6 +289,8 @@
|
|||
<Add option="-littnotify" />
|
||||
<Add option="-ltegra_hal" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/kylin/aarch64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../../../../release/kylin/aarch64 -lHGBase -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
<Add option="-lpthread" />
|
||||
|
@ -276,6 +306,7 @@
|
|||
<Compiler>
|
||||
<Add option="-g" />
|
||||
<Add directory="../../../third_party/opencv/kylin/mips64/include" />
|
||||
<Add directory="../../../third_party/freetype/kylin/mips64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/kylin/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -285,6 +316,8 @@
|
|||
<Add option="-lopencv_imgproc" />
|
||||
<Add option="-lopencv_core" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/kylin/mips64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../HGBase/bin/kylin_mips64_Debug -lHGBase" />
|
||||
<Add option="-L../HGImgFmt/bin/kylin_mips64_Debug -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
|
@ -301,6 +334,7 @@
|
|||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add directory="../../../third_party/opencv/kylin/mips64/include" />
|
||||
<Add directory="../../../third_party/freetype/kylin/mips64/include/freetype2" />
|
||||
<Add directory="../../../third_party/ocr/hanvon/kylin/mips64/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
|
@ -311,6 +345,8 @@
|
|||
<Add option="-lopencv_imgproc" />
|
||||
<Add option="-lopencv_core" />
|
||||
<Add option="-lzlib" />
|
||||
<Add option="-L../../../third_party/freetype/kylin/mips64/lib" />
|
||||
<Add option="-lfreetype" />
|
||||
<Add option="-L../../../../release/kylin/mips64 -lHGBase -lHGImgFmt" />
|
||||
<Add option="-ldl" />
|
||||
<Add option="-lpthread" />
|
||||
|
@ -328,6 +364,8 @@
|
|||
<Add option="-z defs" />
|
||||
<Add option="-B direct" />
|
||||
</Linker>
|
||||
<Unit filename="../../../modules/imgproc/CvxText.cpp" />
|
||||
<Unit filename="../../../modules/imgproc/CvxText.hpp" />
|
||||
<Unit filename="../../../modules/imgproc/HGImgProc.cpp" />
|
||||
<Unit filename="../../../modules/imgproc/HGImgProc.h" />
|
||||
<Unit filename="../../../modules/imgproc/HGImgProcErr.h" />
|
||||
|
|
|
@ -6,6 +6,8 @@ HGImgProc_ResizeImage
|
|||
HGImgProc_ImageAdjustColors
|
||||
HGImgProc_ImageAutoCrop
|
||||
HGImgProc_ImageBlankCheck
|
||||
HGImgProc_ImageDrawLine
|
||||
HGImgProc_AddImageWatermark
|
||||
|
||||
HGImgProc_CreateOCRMgr
|
||||
HGImgProc_DestroyOCRMgr
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\..\modules\imgproc\CvxText.cpp" />
|
||||
<ClCompile Include="..\..\..\modules\imgproc\HGImgProc.cpp" />
|
||||
<ClCompile Include="..\..\..\modules\imgproc\HGOCR.cpp" />
|
||||
<ClCompile Include="..\..\..\modules\imgproc\HGOCRBase.cpp" />
|
||||
|
@ -32,6 +33,7 @@
|
|||
<ClCompile Include="..\..\..\modules\imgproc\ImageProcess\ImageProcess_Public.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\modules\imgproc\CvxText.hpp" />
|
||||
<ClInclude Include="..\..\..\modules\imgproc\HGImgProc.h" />
|
||||
<ClInclude Include="..\..\..\modules\imgproc\HGImgProcErr.h" />
|
||||
<ClInclude Include="..\..\..\modules\imgproc\HGOCR.h" />
|
||||
|
@ -121,7 +123,7 @@
|
|||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/freetype/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -129,8 +131,8 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<ModuleDefinitionFile>HGImgProc.def</ModuleDefinitionFile>
|
||||
<AdditionalDependencies>../Debug/HGBase.lib;../Debug/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x86/opencv_core3416d.lib;../../../third_party/opencv/windows/lib/x86/opencv_highgui3416d.lib;../../../third_party/opencv/windows/lib/x86/opencv_features2d3416d.lib;../../../third_party/opencv/windows/lib/x86/opencv_imgproc3416d.lib;../../../third_party/opencv/windows/lib/x86/ittnotifyd.lib;../../../third_party/opencv/windows/lib/x86/zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>../Debug/HGBase.lib;../Debug/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x86/opencv_core3416d.lib;../../../third_party/opencv/windows/lib/x86/opencv_highgui3416d.lib;../../../third_party/opencv/windows/lib/x86/opencv_features2d3416d.lib;../../../third_party/opencv/windows/lib/x86/opencv_imgproc3416d.lib;../../../third_party/opencv/windows/lib/x86/ittnotifyd.lib;../../../third_party/opencv/windows/lib/x86/zlibd.lib;../../../third_party/freetype/windows/lib/x86/freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/ignore:4099,4098 %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
@ -144,7 +146,7 @@
|
|||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/freetype/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -154,8 +156,8 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<ModuleDefinitionFile>HGImgProc.def</ModuleDefinitionFile>
|
||||
<AdditionalDependencies>../Release/HGBase.lib;../Release/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x86/opencv_core3416.lib;../../../third_party/opencv/windows/lib/x86/opencv_highgui3416.lib;../../../third_party/opencv/windows/lib/x86/opencv_features2d3416.lib;../../../third_party/opencv/windows/lib/x86/opencv_imgproc3416.lib;../../../third_party/opencv/windows/lib/x86/ittnotify.lib;../../../third_party/opencv/windows/lib/x86/zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>../Release/HGBase.lib;../Release/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x86/opencv_core3416.lib;../../../third_party/opencv/windows/lib/x86/opencv_highgui3416.lib;../../../third_party/opencv/windows/lib/x86/opencv_features2d3416.lib;../../../third_party/opencv/windows/lib/x86/opencv_imgproc3416.lib;../../../third_party/opencv/windows/lib/x86/ittnotify.lib;../../../third_party/opencv/windows/lib/x86/zlib.lib;../../../third_party/freetype/windows/lib/x86/freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)HGImgProc.lib $(SolutionDir)..\..\..\sdk\lib\win\x86\Release\
|
||||
|
@ -173,7 +175,7 @@ copy $(OutDir)HGImgProc.dll $(SolutionDir)..\..\..\release\win\x86\Release\</Com
|
|||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/freetype/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -181,8 +183,8 @@ copy $(OutDir)HGImgProc.dll $(SolutionDir)..\..\..\release\win\x86\Release\</Com
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<ModuleDefinitionFile>HGImgProc.def</ModuleDefinitionFile>
|
||||
<AdditionalDependencies>../x64/Debug/HGBase.lib;../x64/Debug/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x64/opencv_core3416d.lib;../../../third_party/opencv/windows/lib/x64/opencv_highgui3416d.lib;../../../third_party/opencv/windows/lib/x64/opencv_features2d3416d.lib;../../../third_party/opencv/windows/lib/x64/opencv_imgproc3416d.lib;../../../third_party/opencv/windows/lib/x64/ittnotifyd.lib;../../../third_party/opencv/windows/lib/x64/zlibd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions> /ignore:4099 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>../x64/Debug/HGBase.lib;../x64/Debug/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x64/opencv_core3416d.lib;../../../third_party/opencv/windows/lib/x64/opencv_highgui3416d.lib;../../../third_party/opencv/windows/lib/x64/opencv_features2d3416d.lib;../../../third_party/opencv/windows/lib/x64/opencv_imgproc3416d.lib;../../../third_party/opencv/windows/lib/x64/ittnotifyd.lib;../../../third_party/opencv/windows/lib/x64/zlibd.lib;../../../third_party/freetype/windows/lib/x64/freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions> /ignore:4099,4098 %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
|
@ -196,7 +198,7 @@ copy $(OutDir)HGImgProc.dll $(SolutionDir)..\..\..\release\win\x86\Release\</Com
|
|||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>../../../third_party/opencv/windows/include;../../../third_party/freetype/windows/include;../../../third_party/ocr/hanvon/windows/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DisableSpecificWarnings>4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
@ -206,8 +208,8 @@ copy $(OutDir)HGImgProc.dll $(SolutionDir)..\..\..\release\win\x86\Release\</Com
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<ModuleDefinitionFile>HGImgProc.def</ModuleDefinitionFile>
|
||||
<AdditionalDependencies>../x64/Release/HGBase.lib;../x64/Release/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x64/opencv_core3416.lib;../../../third_party/opencv/windows/lib/x64/opencv_highgui3416.lib;../../../third_party/opencv/windows/lib/x64/opencv_features2d3416.lib;../../../third_party/opencv/windows/lib/x64/opencv_imgproc3416.lib;../../../third_party/opencv/windows/lib/x64/ittnotify.lib;../../../third_party/opencv/windows/lib/x64/zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>../x64/Release/HGBase.lib;../x64/Release/HGImgFmt.lib;../../../third_party/opencv/windows/lib/x64/opencv_core3416.lib;../../../third_party/opencv/windows/lib/x64/opencv_highgui3416.lib;../../../third_party/opencv/windows/lib/x64/opencv_features2d3416.lib;../../../third_party/opencv/windows/lib/x64/opencv_imgproc3416.lib;../../../third_party/opencv/windows/lib/x64/ittnotify.lib;../../../third_party/opencv/windows/lib/x64/zlib.lib;../../../third_party/freetype/windows/lib/x64/freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/ignore:4099 /LTCG %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)HGImgProc.lib $(SolutionDir)..\..\..\sdk\lib\win\x64\Release\
|
||||
|
|
Binary file not shown.
|
@ -68,6 +68,14 @@ typedef double HGDouble;
|
|||
typedef HGUInt HGUSize;
|
||||
#endif
|
||||
|
||||
typedef HGUInt HGColor;
|
||||
|
||||
#define HG_MAKECOLOR(r, g, b, a) (HGColor)(((HGUInt)a << 24) | ((HGUInt)b << 16) | ((HGUInt)g << 8) | (HGUInt)r)
|
||||
#define HG_GETCOLOR_R(color) (HGUInt)((HGColor)color & 0xFF)
|
||||
#define HG_GETCOLOR_G(color) (HGUInt)(((HGColor)color >> 8) & 0xFF)
|
||||
#define HG_GETCOLOR_B(color) (HGUInt)(((HGColor)color >> 16) & 0xFF)
|
||||
#define HG_GETCOLOR_A(color) (HGUInt)(((HGColor)color >> 24) & 0xFF)
|
||||
|
||||
/* error code */
|
||||
typedef HGUInt HGResult;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <setjmp.h>
|
||||
#include <malloc.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
#include <windows.h>
|
||||
|
|
|
@ -0,0 +1,463 @@
|
|||
#include "CvxText.hpp"
|
||||
#include "../base/HGDef.h"
|
||||
#include "../base/HGInc.h"
|
||||
#include <assert.h>
|
||||
|
||||
CvxText::CvxText()
|
||||
{
|
||||
m_library = NULL;
|
||||
m_face = NULL;
|
||||
}
|
||||
|
||||
CvxText::~CvxText()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
HGResult CvxText::Create(const HGChar* fontPath)
|
||||
{
|
||||
if (NULL != m_face)
|
||||
{
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
FT_Init_FreeType(&m_library);
|
||||
if (NULL == m_library)
|
||||
{
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
FT_New_Face(m_library, fontPath, 0, &m_face);
|
||||
if (NULL == m_face)
|
||||
{
|
||||
FT_Done_FreeType(m_library);
|
||||
m_library = NULL;
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult CvxText::Destroy()
|
||||
{
|
||||
if (NULL == m_face)
|
||||
{
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
FT_Done_Face(m_face);
|
||||
m_face = NULL;
|
||||
FT_Done_FreeType(m_library);
|
||||
m_library = NULL;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
static WCHAR *GetUnicodeStr(const char *text)
|
||||
{
|
||||
int len = ::MultiByteToWideChar(CP_ACP, 0, text, -1, NULL, 0);
|
||||
WCHAR *pUnicode = new WCHAR [len];
|
||||
::MultiByteToWideChar(CP_ACP, 0, text, -1, pUnicode, len);
|
||||
return pUnicode;
|
||||
}
|
||||
#else
|
||||
static uint16_t *GetUnicodeStr(const char *text)
|
||||
{
|
||||
if (0 == *text)
|
||||
{
|
||||
uint16_t *pUnicode = new uint16_t [1];
|
||||
*pUnicode = 0;
|
||||
return pUnicode;
|
||||
}
|
||||
|
||||
uint16_t *pUnicode = new uint16_t [strlen(text) + 2];
|
||||
memset(pUnicode, 0, sizeof(uint16_t) * (strlen(text) + 2));
|
||||
|
||||
iconv_t cd = iconv_open("UNICODE//IGNORE", "UTF-8");
|
||||
if ((iconv_t)-1 != cd)
|
||||
{
|
||||
char *inbuf = (char *)text;
|
||||
size_t inbytes = strlen(text);
|
||||
char *outbuf = (char *)pUnicode;
|
||||
size_t outsize = sizeof(uint16_t) * (strlen(text) + 1);
|
||||
|
||||
iconv(cd, &inbuf, &inbytes, &outbuf, &outsize);
|
||||
iconv_close(cd);
|
||||
}
|
||||
|
||||
return pUnicode;
|
||||
}
|
||||
#endif
|
||||
|
||||
HGResult CvxText::DrawString(HGImage image, const HGChar* text, HGColor color, HGUInt posType, HGInt locationX, HGInt locationY,
|
||||
HGUInt fontSize, HGBool bold, HGBool underline, HGBool italic, HGBool strikeout)
|
||||
{
|
||||
if (NULL == m_face)
|
||||
{
|
||||
return HGBASE_ERR_FAIL;
|
||||
}
|
||||
|
||||
assert(NULL != image);
|
||||
assert(NULL != text && '\0' != *text);
|
||||
assert(posType >= HGIMGPROC_WMPOSTYPE_LEFT && posType <= HGIMGPROC_WMPOSTYPE_LOCATION);
|
||||
assert(0 != fontSize);
|
||||
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = DrawString(imageTmp, text, color, posType, locationX, locationY, fontSize, bold, underline, italic, strikeout);
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGUInt width, height;
|
||||
std::vector<HGRect> vPos;
|
||||
GetStringLocation(text, fontSize, bold, underline, italic, strikeout, width, height, vPos);
|
||||
|
||||
if (HGIMGPROC_WMPOSTYPE_LOCATION == posType)
|
||||
{
|
||||
#if defined(HG_CMP_MSC)
|
||||
WCHAR* pUnicode = GetUnicodeStr(text);
|
||||
#else
|
||||
uint16_t* pUnicode = GetUnicodeStr(text);
|
||||
uint16_t* pUnicodeEx = pUnicode + 1;
|
||||
#endif
|
||||
|
||||
int i = 0;
|
||||
#if defined(HG_CMP_MSC)
|
||||
while ('\0' != pUnicode[i])
|
||||
#else
|
||||
while ('\0' != pUnicodeEx[i])
|
||||
#endif
|
||||
{
|
||||
#if defined(HG_CMP_MSC)
|
||||
DrawChar(image, pUnicode[i], color, locationX + vPos[i].left, locationY + vPos[i].top, fontSize, bold, italic);
|
||||
#else
|
||||
DrawChar(image, pUnicodeEx[i], color, locationX + vPos[i].left, locationY + vPos[i].top, fontSize, bold, italic);
|
||||
#endif
|
||||
++i;
|
||||
}
|
||||
|
||||
delete[] pUnicode;
|
||||
|
||||
if (underline)
|
||||
{
|
||||
HGImgProc_ImageDrawLine(image, locationX, locationY + height - 1,
|
||||
locationX + width, locationY + height - 1, color, 1, HGIMGPROC_LINETYPE_SOLID);
|
||||
}
|
||||
|
||||
if (strikeout)
|
||||
{
|
||||
if (underline)
|
||||
HGImgProc_ImageDrawLine(image, locationX, locationY + (height - 1) / 2,
|
||||
locationX + width, locationY + (height - 1) / 2, color, 1, HGIMGPROC_LINETYPE_SOLID);
|
||||
else
|
||||
HGImgProc_ImageDrawLine(image, locationX, locationY + height / 2,
|
||||
locationX + width, locationY + height / 2, color, 1, HGIMGPROC_LINETYPE_SOLID);
|
||||
}
|
||||
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGImageRoi imgRoi;
|
||||
HGBase_GetImageROI(image, &imgRoi);
|
||||
HGInt roiWidth = imgRoi.right - imgRoi.left;
|
||||
HGInt roiHeight = imgRoi.bottom - imgRoi.top;
|
||||
|
||||
HGInt x, y;
|
||||
if (HGIMGPROC_WMPOSTYPE_LEFT == posType)
|
||||
{
|
||||
x = 0;
|
||||
y = (roiHeight - height) / 2;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_TOP == posType)
|
||||
{
|
||||
x = (roiWidth - width) / 2;
|
||||
y = 0;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_RIGHT == posType)
|
||||
{
|
||||
x = roiWidth - width;
|
||||
y = (roiHeight - height) / 2;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_BOTTOM == posType)
|
||||
{
|
||||
x = (roiWidth - width) / 2;
|
||||
y = roiHeight - height;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_LEFTTOP == posType)
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_RIGHTTOP == posType)
|
||||
{
|
||||
x = roiWidth - width;
|
||||
y = 0;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_LEFTBOTTOM == posType)
|
||||
{
|
||||
x = 0;
|
||||
y = roiHeight - height;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_RIGHTBOTTOM == posType)
|
||||
{
|
||||
x = roiWidth - width;
|
||||
y = roiHeight - height;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = (roiWidth - width) / 2;
|
||||
y = (roiHeight - height) / 2;
|
||||
}
|
||||
|
||||
return DrawString(image, text, color, HGIMGPROC_WMPOSTYPE_LOCATION, x, y, fontSize, bold, underline, italic, strikeout);
|
||||
}
|
||||
|
||||
void CvxText::MeasureChar(HGUInt wc, HGUInt fontSize, HGBool bold, HGBool italic, FT_BBox& acbox)
|
||||
{
|
||||
assert(NULL != m_face);
|
||||
assert(0 != fontSize);
|
||||
|
||||
FT_Set_Pixel_Sizes(m_face, fontSize, fontSize);
|
||||
FT_UInt glyph_index = FT_Get_Char_Index(m_face, wc);
|
||||
FT_Load_Glyph(m_face, glyph_index, FT_LOAD_DEFAULT);
|
||||
|
||||
if (bold)
|
||||
{
|
||||
if (m_face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
FT_Outline_Embolden(&m_face->glyph->outline, fontSize * 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (italic)
|
||||
{
|
||||
if (m_face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
FT_Matrix matrix;
|
||||
matrix.xx = 0x10000L;
|
||||
matrix.xy = 0.4f * 0x10000L;
|
||||
matrix.yx = 0;
|
||||
matrix.yy = 0x10000L;
|
||||
FT_Outline_Transform(&m_face->glyph->outline, &matrix);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_face->glyph->format != FT_GLYPH_FORMAT_BITMAP)
|
||||
{
|
||||
FT_Render_Glyph(m_face->glyph, FT_RENDER_MODE_NORMAL);
|
||||
}
|
||||
|
||||
FT_Glyph glyph;
|
||||
FT_Get_Glyph(m_face->glyph, &glyph);
|
||||
FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_TRUNCATE, &acbox);
|
||||
}
|
||||
|
||||
void CvxText::GetStringLocation(const HGChar* text, HGUInt fontSize, HGBool bold, HGBool underline, HGBool italic, HGBool strikeout,
|
||||
HGUInt& width, HGUInt& height, std::vector<HGRect> &vPos)
|
||||
{
|
||||
assert(NULL != text && '\0' != *text);
|
||||
assert(0 != fontSize);
|
||||
|
||||
width = 0;
|
||||
height = 0;
|
||||
vPos.clear();
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
WCHAR* pUnicode = GetUnicodeStr(text);
|
||||
#else
|
||||
uint16_t* pUnicode = GetUnicodeStr(text);
|
||||
uint16_t* pUnicodeEx = pUnicode + 1;
|
||||
#endif
|
||||
|
||||
HGInt origin = 0;
|
||||
HGInt minY = INT_MAX, maxY = INT_MIN;
|
||||
|
||||
int i = 0;
|
||||
#if defined(HG_CMP_MSC)
|
||||
while ('\0' != pUnicode[i])
|
||||
#else
|
||||
while ('\0' != pUnicodeEx[i])
|
||||
#endif
|
||||
{
|
||||
FT_BBox acbox;
|
||||
#if defined(HG_CMP_MSC)
|
||||
MeasureChar(pUnicode[i], fontSize, bold, italic, acbox);
|
||||
#else
|
||||
MeasureChar(pUnicodeEx[i], fontSize, bold, italic, acbox);
|
||||
#endif
|
||||
|
||||
HGRect pos;
|
||||
pos.left = origin + acbox.xMin;
|
||||
pos.right = origin + acbox.xMax;
|
||||
pos.top = -acbox.yMax;
|
||||
pos.bottom = -acbox.yMin;
|
||||
vPos.push_back(pos);
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
if (pUnicode[i] < 255 && (!isprint((int)pUnicode[i]) || isspace((int)pUnicode[i])))
|
||||
#else
|
||||
if (pUnicodeEx[i] < 255 && (!isprint((int)pUnicodeEx[i]) || isspace((int)pUnicodeEx[i])))
|
||||
#endif
|
||||
{
|
||||
origin += fontSize / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
origin += (acbox.xMax + acbox.xMin);
|
||||
}
|
||||
|
||||
if (acbox.yMin < minY)
|
||||
minY = acbox.yMin;
|
||||
if (acbox.yMax > maxY)
|
||||
maxY = acbox.yMax;
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
delete[] pUnicode;
|
||||
|
||||
width = origin;
|
||||
height = (maxY - minY);
|
||||
if (underline)
|
||||
++height;
|
||||
|
||||
for (int i = 0; i < (int)vPos.size(); ++i)
|
||||
{
|
||||
vPos[i].top += maxY;
|
||||
vPos[i].bottom += maxY;
|
||||
}
|
||||
}
|
||||
|
||||
void CvxText::DrawChar(HGImage image, HGUInt wc, HGColor color, HGInt x, HGInt y, HGUInt fontSize, HGBool bold, HGBool italic)
|
||||
{
|
||||
assert(NULL != m_face);
|
||||
assert(NULL != image);
|
||||
assert(0 != fontSize);
|
||||
|
||||
FT_Set_Pixel_Sizes(m_face, fontSize, fontSize);
|
||||
FT_UInt glyph_index = FT_Get_Char_Index(m_face, wc);
|
||||
FT_Load_Glyph(m_face, glyph_index, FT_LOAD_DEFAULT);
|
||||
|
||||
if (bold)
|
||||
{
|
||||
if (m_face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
FT_Outline_Embolden(&m_face->glyph->outline, fontSize * 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (italic)
|
||||
{
|
||||
if (m_face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
FT_Matrix matrix;
|
||||
matrix.xx = 0x10000L;
|
||||
matrix.xy = 0.4f * 0x10000L;
|
||||
matrix.yx = 0;
|
||||
matrix.yy = 0x10000L;
|
||||
FT_Outline_Transform(&m_face->glyph->outline, &matrix);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_face->glyph->format != FT_GLYPH_FORMAT_BITMAP)
|
||||
{
|
||||
FT_Render_Glyph(m_face->glyph, FT_RENDER_MODE_NORMAL);
|
||||
}
|
||||
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
uint32_t imgWidth = imgInfo.width;
|
||||
uint32_t imgHeight = imgInfo.height;
|
||||
uint32_t imgWidthStep = imgInfo.widthStep;
|
||||
uint32_t imgType = imgInfo.type;
|
||||
|
||||
uint8_t *imgData;
|
||||
HGBase_GetImageData(image, &imgData);
|
||||
|
||||
int32_t imgChannel = 0;
|
||||
if (HGBASE_IMGTYPE_GRAY == imgType)
|
||||
imgChannel = 1;
|
||||
else if (HGBASE_IMGTYPE_RGB == imgType || HGBASE_IMGTYPE_BGR == imgType)
|
||||
imgChannel = 3;
|
||||
else if (HGBASE_IMGTYPE_RGBA == imgType || HGBASE_IMGTYPE_BGRA == imgType)
|
||||
imgChannel = 4;
|
||||
assert(0 != imgChannel);
|
||||
|
||||
HGImageRoi imgRoi;
|
||||
HGBase_GetImageROI(image, &imgRoi);
|
||||
uint32_t imgLeft = imgRoi.left;
|
||||
uint32_t imgTop = imgRoi.top;
|
||||
uint32_t imgRight = imgRoi.right;
|
||||
uint32_t imgBottom = imgRoi.bottom;
|
||||
|
||||
for (unsigned int i = 0; i < m_face->glyph->bitmap.rows; ++i)
|
||||
{
|
||||
for (unsigned int j = 0; j < m_face->glyph->bitmap.width; ++j)
|
||||
{
|
||||
int32_t xOffset = (int32_t)imgLeft + x + (int32_t)j;
|
||||
int32_t yOffset = (int32_t)imgTop + y + (int32_t)i;
|
||||
|
||||
if (xOffset >= (int32_t)imgLeft && xOffset < (int32_t)imgRight
|
||||
&& yOffset >= (int32_t)imgTop && yOffset < (int32_t)imgBottom)
|
||||
{
|
||||
uint8_t *p = m_face->glyph->bitmap.buffer + m_face->glyph->bitmap.pitch * i + j;
|
||||
int32_t opacity = HG_GETCOLOR_A(color) * (*p) / 255;
|
||||
|
||||
uint8_t *pEx = imgData + yOffset * imgWidthStep + xOffset * imgChannel;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == imgInfo.origin)
|
||||
pEx = imgData + (imgHeight - yOffset - 1) * imgWidthStep + xOffset * imgChannel;
|
||||
|
||||
if (HGBASE_IMGTYPE_RGB == imgType || HGBASE_IMGTYPE_RGBA == imgType)
|
||||
{
|
||||
int32_t v0 = HG_GETCOLOR_R(color);
|
||||
int32_t vDest0 = pEx[0];
|
||||
int32_t value0 = (v0 - vDest0) * opacity;
|
||||
pEx[0] = (uint8_t)(vDest0 + (((value0 << 8) + value0) >> 16));
|
||||
|
||||
int32_t v1 = HG_GETCOLOR_G(color);
|
||||
int32_t vDest1 = pEx[1];
|
||||
int32_t value1 = (v1 - vDest1) * opacity;
|
||||
pEx[1] = (uint8_t)(vDest1 + (((value1 << 8) + value1) >> 16));
|
||||
|
||||
int32_t v2 = HG_GETCOLOR_B(color);
|
||||
int32_t vDest2 = pEx[2];
|
||||
int32_t value2 = (v2 - vDest2) * opacity;
|
||||
pEx[2] = (uint8_t)(vDest2 + (((value2 << 8) + value2) >> 16));
|
||||
}
|
||||
else if (HGBASE_IMGTYPE_BGR == imgType || HGBASE_IMGTYPE_BGRA == imgType)
|
||||
{
|
||||
int32_t v0 = HG_GETCOLOR_B(color);
|
||||
int32_t vDest0 = pEx[0];
|
||||
int32_t value0 = (v0 - vDest0) * opacity;
|
||||
pEx[0] = (uint8_t)(vDest0 + (((value0 << 8) + value0) >> 16));
|
||||
|
||||
int32_t v1 = HG_GETCOLOR_G(color);
|
||||
int32_t vDest1 = pEx[1];
|
||||
int32_t value1 = (v1 - vDest1) * opacity;
|
||||
pEx[1] = (uint8_t)(vDest1 + (((value1 << 8) + value1) >> 16));
|
||||
|
||||
int32_t v2 = HG_GETCOLOR_R(color);
|
||||
int32_t vDest2 = pEx[2];
|
||||
int32_t value2 = (v2 - vDest2) * opacity;
|
||||
pEx[2] = (uint8_t)(vDest2 + (((value2 << 8) + value2) >> 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t v = (HG_GETCOLOR_R(color) * 76 + HG_GETCOLOR_G(color) * 150 + HG_GETCOLOR_B(color) * 30) >> 8;
|
||||
int32_t vDest = *pEx;
|
||||
int32_t value = (v - vDest) * opacity;
|
||||
*pEx = (uint8_t)(vDest + (((value << 8) + value) >> 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef __CVXTEXT_H__
|
||||
#define __CVXTEXT_H__
|
||||
|
||||
#include "HGImgProc.h"
|
||||
#include <ft2build.h>
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftbitmap.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
#include <vector>
|
||||
|
||||
class CvxText
|
||||
{
|
||||
public:
|
||||
CvxText();
|
||||
~CvxText();
|
||||
|
||||
HGResult Create(const HGChar *fontPath);
|
||||
HGResult Destroy();
|
||||
HGResult DrawString(HGImage image, const HGChar* text, HGColor color, HGUInt posType, HGInt locationX, HGInt locationY,
|
||||
HGUInt fontSize, HGBool bold, HGBool underline, HGBool italic, HGBool strikeout);
|
||||
|
||||
private:
|
||||
void MeasureChar(HGUInt wc, HGUInt fontSize, HGBool bold, HGBool italic, FT_BBox& acbox);
|
||||
void GetStringLocation(const HGChar* text, HGUInt fontSize, HGBool bold, HGBool underline, HGBool italic, HGBool strikeout,
|
||||
HGUInt &width, HGUInt &height, std::vector<HGRect> &vPos);
|
||||
void DrawChar(HGImage image, HGUInt wc, HGColor color, HGInt x, HGInt y, HGUInt fontSize, HGBool bold, HGBool italic);
|
||||
|
||||
private:
|
||||
FT_Library m_library;
|
||||
FT_Face m_face;
|
||||
};
|
||||
|
||||
#endif /* __CVXTEXT_H__ */
|
|
@ -2,8 +2,9 @@
|
|||
#include "./ImageProcess/ImageApplyAdjustColors.h"
|
||||
#include "./ImageProcess/ImageApplyAutoCrop.h"
|
||||
#include "./ImageProcess/ImageApplyDiscardBlank.h"
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "CvxText.hpp"
|
||||
#include "../base/HGInc.h"
|
||||
#include "../base/HGUtility.h"
|
||||
|
||||
HGResult HGAPI HGImgProc_ResizeImage(HGImage image, HGImage destImage, HGUInt interp)
|
||||
{
|
||||
|
@ -81,7 +82,12 @@ HGResult HGAPI HGImgProc_ResizeImage(HGImage image, HGImage destImage, HGUInt in
|
|||
channels = 4;
|
||||
|
||||
uint8_t* p = data + roi.top * imgInfo.widthStep + roi.left * channels;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == imgInfo.origin)
|
||||
p = data + (imgInfo.height - roi.bottom) * imgInfo.widthStep + roi.left * channels;
|
||||
|
||||
uint8_t* pDest = destData + destRoi.top * destImgInfo.widthStep + destRoi.left * channels;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == destImgInfo.origin)
|
||||
pDest = destData + (destImgInfo.height - destRoi.bottom) * destImgInfo.widthStep + destRoi.left * channels;
|
||||
|
||||
IplImage* pImg = cvCreateImageHeader(cvSize(roiWidth, roiHeight), IPL_DEPTH_8U, channels);
|
||||
IplImage* pImgDest = cvCreateImageHeader(cvSize(destRoiWidth, destRoiHeight), IPL_DEPTH_8U, channels);
|
||||
|
@ -147,8 +153,10 @@ HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destImage,
|
|||
}
|
||||
|
||||
uint8_t* p = data + roi.top * imgInfo.widthStep + roi.left * channels;
|
||||
cv::Mat img(roiHeight, roiWidth, CV_8UC(channels), p, imgInfo.widthStep);
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == imgInfo.origin)
|
||||
p = data + (imgInfo.height - roi.bottom) * imgInfo.widthStep + roi.left * channels;
|
||||
|
||||
cv::Mat img(roiHeight, roiWidth, CV_8UC(channels), p, imgInfo.widthStep);
|
||||
CImageApplyAdjustColors imgApply(brightness, contrast, gamma);
|
||||
imgApply.apply(img, 0);
|
||||
}
|
||||
|
@ -196,8 +204,10 @@ HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destImage,
|
|||
HGBase_CopyImage(image, destImage);
|
||||
|
||||
uint8_t* pDest = destData + destRoi.top * destImgInfo.widthStep + destRoi.left * channels;
|
||||
cv::Mat destImg(destRoiHeight, destRoiWidth, CV_8UC(channels), pDest, destImgInfo.widthStep);
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == destImgInfo.origin)
|
||||
pDest = destData + (destImgInfo.height - destRoi.bottom) * destImgInfo.widthStep + destRoi.left * channels;
|
||||
|
||||
cv::Mat destImg(destRoiHeight, destRoiWidth, CV_8UC(channels), pDest, destImgInfo.widthStep);
|
||||
CImageApplyAdjustColors imgApply(brightness, contrast, gamma);
|
||||
imgApply.apply(destImg, 0);
|
||||
}
|
||||
|
@ -267,6 +277,9 @@ HGResult HGAPI HGImgProc_ImageAutoCrop(HGImage image, HGBool autoCrop, HGBool de
|
|||
channels = 3;
|
||||
|
||||
uint8_t* p = data + roi.top * imgInfo.widthStep + roi.left * channels;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == imgInfo.origin)
|
||||
p = data + (imgInfo.height - roi.bottom) * imgInfo.widthStep + roi.left * channels;
|
||||
|
||||
cv::Mat img(roiHeight, roiWidth, CV_8UC(channels), p, imgInfo.widthStep);
|
||||
|
||||
cv::Mat destImg;
|
||||
|
@ -343,9 +356,129 @@ HGResult HGAPI HGImgProc_ImageBlankCheck(HGImage image, const HGImgBlankCheckPar
|
|||
channels = 3;
|
||||
|
||||
uint8_t* p = data + roi.top * imgInfo.widthStep + roi.left * channels;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == imgInfo.origin)
|
||||
p = data + (imgInfo.height - roi.bottom) * imgInfo.widthStep + roi.left * channels;
|
||||
|
||||
cv::Mat img(roiHeight, roiWidth, CV_8UC(channels), p, imgInfo.widthStep);
|
||||
|
||||
bool ret = CImageApplyDiscardBlank::apply(img, threshold, edge, blockSize, devTh, meanTh);
|
||||
*blank = ret ? HGTRUE : HGFALSE;
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGImgProc_ImageDrawLine(HGImage image, HGInt x1, HGInt y1, HGInt x2, HGInt y2,
|
||||
HGColor color, HGUInt width, HGUInt type)
|
||||
{
|
||||
if (NULL == image || 0 == width || type < HGIMGPROC_LINETYPE_SOLID || type > HGIMGPROC_LINETYPE_DASH)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type || HGBASE_IMGTYPE_GRAY == imgInfo.type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_RGB, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGImgProc_ImageDrawLine(imageTmp, x1, y1, x2, y2, color, width, type);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, image);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* data = NULL;
|
||||
HGBase_GetImageData(image, &data);
|
||||
|
||||
HGImageRoi roi;
|
||||
HGBase_GetImageROI(image, &roi);
|
||||
HGUInt roiWidth = roi.right - roi.left;
|
||||
HGUInt roiHeight = roi.bottom - roi.top;
|
||||
|
||||
uint32_t channels = 3;
|
||||
if (HGBASE_IMGTYPE_BGRA == imgInfo.type || HGBASE_IMGTYPE_RGBA == imgInfo.type)
|
||||
channels = 4;
|
||||
|
||||
uint8_t* p = data + roi.top * imgInfo.widthStep + roi.left * channels;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == imgInfo.origin)
|
||||
p = data + (imgInfo.height - roi.bottom) * imgInfo.widthStep + roi.left * channels;
|
||||
|
||||
IplImage* pImg = cvCreateImageHeader(cvSize(roiWidth, roiHeight), IPL_DEPTH_8U, channels);
|
||||
cvSetData(pImg, p, imgInfo.widthStep);
|
||||
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == imgInfo.origin)
|
||||
{
|
||||
y1 = roiHeight - y1 - 1;
|
||||
y2 = roiHeight - y2 - 1;
|
||||
}
|
||||
|
||||
HGUInt r = HG_GETCOLOR_R(color);
|
||||
HGUInt g = HG_GETCOLOR_G(color);
|
||||
HGUInt b = HG_GETCOLOR_B(color);
|
||||
if (HGBASE_IMGTYPE_BGR == imgInfo.type || HGBASE_IMGTYPE_BGRA == imgInfo.type)
|
||||
{
|
||||
r = HG_GETCOLOR_B(color);
|
||||
g = HG_GETCOLOR_G(color);
|
||||
b = HG_GETCOLOR_R(color);
|
||||
}
|
||||
|
||||
cvLine(pImg, cvPoint(x1, y1), cvPoint(x2, y2), cvScalar(r, g, b), width);
|
||||
cvReleaseImageHeader(&pImg);
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGResult HGAPI HGImgProc_AddImageWatermark(HGImage image, const HGChar* text, HGColor color, HGUInt posType,
|
||||
HGInt locationX, HGInt locationY, const HGImgWatermarkFontParam *fontParam)
|
||||
{
|
||||
if (NULL == image || NULL == text || '\0' == *text || posType < HGIMGPROC_WMPOSTYPE_LEFT
|
||||
|| posType > HGIMGPROC_WMPOSTYPE_LOCATION)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
std::string fontName = "宋体";
|
||||
HGUInt fontSize = 20;
|
||||
HGBool bold = HGFALSE;
|
||||
HGBool underline = HGFALSE;
|
||||
HGBool italic = HGFALSE;
|
||||
HGBool strikeout = HGFALSE;
|
||||
|
||||
if (NULL != fontParam)
|
||||
{
|
||||
if (0 == fontParam->fontSize)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDARG;
|
||||
}
|
||||
|
||||
fontName = fontParam->foneName;
|
||||
fontSize = fontParam->fontSize;
|
||||
bold = fontParam->bold;
|
||||
underline = fontParam->underline;
|
||||
italic = fontParam->italic;
|
||||
strikeout = fontParam->strikeout;
|
||||
}
|
||||
|
||||
HGChar moduleName[256];
|
||||
HGBase_GetModuleName((void *)HGImgProc_AddImageWatermark, moduleName, 256);
|
||||
HGChar modulePath[256];
|
||||
HGBase_GetFilePath(moduleName, modulePath, 256);
|
||||
HGChar fontPath[256];
|
||||
sprintf(fontPath, "%s%s.ttf", modulePath, fontName.c_str());
|
||||
|
||||
CvxText cvxText;
|
||||
HGResult ret = cvxText.Create(fontPath);
|
||||
if (HGBASE_ERR_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = cvxText.DrawString(image, text, color, posType, locationX, locationY, fontSize, bold, underline, italic, strikeout);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,32 @@
|
|||
/* 双线性插值 */
|
||||
#define HGIMGPROC_INTERPOTYPE_LINEAR 2L
|
||||
|
||||
/* 线条类型-实线 */
|
||||
#define HGIMGPROC_LINETYPE_SOLID 1L
|
||||
/* 线条类型-虚线 */
|
||||
#define HGIMGPROC_LINETYPE_DASH 2L
|
||||
|
||||
/* 水印位置-左侧 */
|
||||
#define HGIMGPROC_WMPOSTYPE_LEFT 1L
|
||||
/* 水印位置-上侧 */
|
||||
#define HGIMGPROC_WMPOSTYPE_TOP 2L
|
||||
/* 水印位置-右侧 */
|
||||
#define HGIMGPROC_WMPOSTYPE_RIGHT 3L
|
||||
/* 水印位置-下侧 */
|
||||
#define HGIMGPROC_WMPOSTYPE_BOTTOM 4L
|
||||
/* 水印位置-左上 */
|
||||
#define HGIMGPROC_WMPOSTYPE_LEFTTOP 5L
|
||||
/* 水印位置-右上 */
|
||||
#define HGIMGPROC_WMPOSTYPE_RIGHTTOP 6L
|
||||
/* 水印位置-左下 */
|
||||
#define HGIMGPROC_WMPOSTYPE_LEFTBOTTOM 7L
|
||||
/* 水印位置-右下 */
|
||||
#define HGIMGPROC_WMPOSTYPE_RIGHTBOTTOM 8L
|
||||
/* 水印位置-中间 */
|
||||
#define HGIMGPROC_WMPOSTYPE_CENTER 9L
|
||||
/* 水印位置-自定义 */
|
||||
#define HGIMGPROC_WMPOSTYPE_LOCATION 10L
|
||||
|
||||
/* 自动裁剪参数 */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -33,6 +59,17 @@ typedef struct
|
|||
HGDouble meanTh; /* 默认200 */
|
||||
}HGImgBlankCheckParam;
|
||||
|
||||
/* 水印字体参数 */
|
||||
typedef struct
|
||||
{
|
||||
HGChar foneName[64]; /* 字体名, windows上为GBK编码, linux上为UTF8编码 */
|
||||
HGUInt fontSize; /* 字号 */
|
||||
HGBool bold; /* 是否粗体 */
|
||||
HGBool underline; /* 是否有下划线 */
|
||||
HGBool italic; /* 是否斜体 */
|
||||
HGBool strikeout; /* 是否有删除线 */
|
||||
}HGImgWatermarkFontParam;
|
||||
|
||||
/* 图像缩放
|
||||
* 参数:
|
||||
* 1) image: in, 源图像句柄
|
||||
|
@ -89,4 +126,33 @@ HGEXPORT HGResult HGAPI HGImgProc_ImageAutoCrop(HGImage image, HGBool autoCrop,
|
|||
*/
|
||||
HGEXPORT HGResult HGAPI HGImgProc_ImageBlankCheck(HGImage image, const HGImgBlankCheckParam *param, HGBool *blank);
|
||||
|
||||
/* 图像画线
|
||||
* 1) image: in, 图像句柄
|
||||
* 2) x1: in, 第一个点x坐标
|
||||
* 3) y1: in, 第一个点y坐标
|
||||
* 4) x2: in, 第二个点x坐标
|
||||
* 5) y2: in, 第二个点y坐标
|
||||
* 6) color: in, 颜色
|
||||
* 7) width: in, 线宽
|
||||
* 8) type: in, 表示线类型, 参见HGIMGPROC_LINETYPE_*
|
||||
* 说明:
|
||||
* 1) 操作的只是图像的ROI区域
|
||||
*/
|
||||
HGEXPORT HGResult HGAPI HGImgProc_ImageDrawLine(HGImage image, HGInt x1, HGInt y1, HGInt x2, HGInt y2,
|
||||
HGColor color, HGUInt width, HGUInt type);
|
||||
|
||||
/* 添加图像水印
|
||||
* 1) image: in, 图像句柄
|
||||
* 2) text: 水印文本, windows上为GBK编码, linux上为UTF8编码
|
||||
* 3) color: 颜色
|
||||
* 4) posType: 位置, 见HGIMGPROC_WMPOSTYPE_*
|
||||
* 5) locationX: 当posType为HGIMGPROC_WMPOSTYPE_LOCATION时表示x坐标
|
||||
* 6) locationY: 当posType为HGIMGPROC_WMPOSTYPE_LOCATION时表示y坐标
|
||||
* 7) fontParam: 字体参数, 为NULL时使用默认参数
|
||||
* 说明:
|
||||
* 1) 操作的只是图像的ROI区域
|
||||
*/
|
||||
HGEXPORT HGResult HGAPI HGImgProc_AddImageWatermark(HGImage image, const HGChar *text, HGColor color, HGUInt posType,
|
||||
HGInt locationX, HGInt locationY, const HGImgWatermarkFontParam *fontParam);
|
||||
|
||||
#endif /* __HGIMGPROC_H__ */
|
|
@ -57,13 +57,6 @@ namespace ver_2
|
|||
m_globalCfg.imageJpegQuality = GetCfgIntValue("global", "imageJpegQuality", 80);
|
||||
m_globalCfg.imageTiffCompression = GetCfgStringValue("global", "imageTiffCompression", "lzw");
|
||||
m_globalCfg.imageTiffJpegQuality = GetCfgIntValue("global", "imageTiffJpegQuality", 80);
|
||||
m_globalCfg.uploadHttpHost = GetCfgStringValue("global", "uploadHttpHost", "");
|
||||
m_globalCfg.uploadHttpPort = GetCfgIntValue("global", "uploadHttpPort", 80);
|
||||
m_globalCfg.uploadHttpPath = GetCfgStringValue("global", "uploadHttpPath", "/upload.cgi");
|
||||
m_globalCfg.uploadFtpUser = GetCfgStringValue("global", "uploadFtpUser", "");
|
||||
m_globalCfg.uploadFtpPassword = GetCfgStringValue("global", "uploadFtpPassword", "");
|
||||
m_globalCfg.uploadFtpHost = GetCfgStringValue("global", "uploadFtpHost", "");
|
||||
m_globalCfg.uploadFtpPort = GetCfgIntValue("global", "uploadFtpPort", 21);
|
||||
|
||||
m_globalCfg.fileSavePath.push_back('/');
|
||||
HGChar stdSavePath[256];
|
||||
|
@ -280,41 +273,6 @@ namespace ver_2
|
|||
m_globalCfg.imageTiffJpegQuality = cfg.imageTiffJpegQuality;
|
||||
SetCfgIntValue("global", "imageTiffJpegQuality", m_globalCfg.imageTiffJpegQuality);
|
||||
}
|
||||
if (mask & GlobalConfig::uploadHttpHostMask)
|
||||
{
|
||||
m_globalCfg.uploadHttpHost = cfg.uploadHttpHost;
|
||||
SetCfgStringValue("global", "uploadHttpHost", m_globalCfg.uploadHttpHost);
|
||||
}
|
||||
if (mask & GlobalConfig::uploadHttpPortMask)
|
||||
{
|
||||
m_globalCfg.uploadHttpPort = cfg.uploadHttpPort;
|
||||
SetCfgIntValue("global", "uploadHttpPort", m_globalCfg.uploadHttpPort);
|
||||
}
|
||||
if (mask & GlobalConfig::uploadHttpPathMask)
|
||||
{
|
||||
m_globalCfg.uploadHttpPath = cfg.uploadHttpPath;
|
||||
SetCfgStringValue("global", "uploadHttpPath", m_globalCfg.uploadHttpPath);
|
||||
}
|
||||
if (mask & GlobalConfig::uploadFtpUserMask)
|
||||
{
|
||||
m_globalCfg.uploadFtpUser = cfg.uploadFtpUser;
|
||||
SetCfgStringValue("global", "uploadFtpUser", m_globalCfg.uploadFtpUser);
|
||||
}
|
||||
if (mask & GlobalConfig::uploadFtpPasswordMask)
|
||||
{
|
||||
m_globalCfg.uploadFtpPassword = cfg.uploadFtpPassword;
|
||||
SetCfgStringValue("global", "uploadFtpPassword", m_globalCfg.uploadFtpPassword);
|
||||
}
|
||||
if (mask & GlobalConfig::uploadFtpHostMask)
|
||||
{
|
||||
m_globalCfg.uploadFtpHost = cfg.uploadFtpHost;
|
||||
SetCfgStringValue("global", "uploadFtpHost", m_globalCfg.uploadFtpHost);
|
||||
}
|
||||
if (mask & GlobalConfig::uploadFtpPortMask)
|
||||
{
|
||||
m_globalCfg.uploadFtpPort = cfg.uploadFtpPort;
|
||||
SetCfgIntValue("global", "uploadFtpPort", m_globalCfg.uploadFtpPort);
|
||||
}
|
||||
HGBase_LeaveLock(m_lock);
|
||||
|
||||
errInfo.clear();
|
||||
|
@ -840,25 +798,200 @@ namespace ver_2
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ManagerV2::UploadLocalFile(const std::string& filePath, const std::string& mode, const std::string& remoteFilePath, std::string& errInfo)
|
||||
static int tolower(int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
{
|
||||
return c + 'a' - 'A';
|
||||
}
|
||||
else
|
||||
{
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
static int htoi(char s[])
|
||||
{
|
||||
int i;
|
||||
int n = 0;
|
||||
if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
|
||||
{
|
||||
i = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 0;
|
||||
}
|
||||
for (; (s[i] >= '0' && s[i] <= '9') || (s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'); ++i)
|
||||
{
|
||||
if (tolower(s[i]) > '9')
|
||||
{
|
||||
n = 16 * n + (10 + tolower(s[i]) - 'a');
|
||||
}
|
||||
else
|
||||
{
|
||||
n = 16 * n + (tolower(s[i]) - '0');
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
int ManagerV2::LocalImageAddWatermark(const std::string& imagePath, const std::string& text, const std::string& textColor, int textOpacity, const std::string& textPos,
|
||||
int marginLeft, int marginTop, int marginRight, int marginBottom, int locationX, int locationY, const std::string& fontName,
|
||||
int fontSize, bool fontBold, bool fontUnderline, bool fontItalic, bool fontStrikeout, std::string& outImagePath, std::string& errInfo)
|
||||
{
|
||||
outImagePath.clear();
|
||||
errInfo = "错误";
|
||||
|
||||
if (imagePath.empty() || text.empty() || 7 != textColor.size() || textOpacity < 0 || textOpacity > 255 || marginLeft < 0 || marginTop < 0
|
||||
|| marginRight < 0 || marginBottom < 0 || fontName.empty() || fontSize <= 0)
|
||||
return -1;
|
||||
|
||||
HGUInt posType = 0;
|
||||
if ("left" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_LEFT;
|
||||
else if ("top" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_TOP;
|
||||
else if ("right" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_RIGHT;
|
||||
else if ("bottom" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_BOTTOM;
|
||||
else if ("left_top" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_LEFTTOP;
|
||||
else if ("right_top" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_RIGHTTOP;
|
||||
else if ("left_bottom" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_LEFTBOTTOM;
|
||||
else if ("right_bottom" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_RIGHTBOTTOM;
|
||||
else if ("center" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_CENTER;
|
||||
else if ("location" == textPos)
|
||||
posType = HGIMGPROC_WMPOSTYPE_LOCATION;
|
||||
if (0 == posType)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ('#' != textColor[0])
|
||||
return -1;
|
||||
for (int i = 1; i < (int)textColor.size(); ++i)
|
||||
{
|
||||
if ((textColor[i] >= '0' && textColor[i] <= '9') || (textColor[i] >= 'a' && textColor[i] <= 'f')
|
||||
|| (textColor[i] >= 'A' && textColor[i] <= 'F'))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
char colorR[3] = { 0 };
|
||||
char colorG[3] = { 0 };
|
||||
char colorB[3] = { 0 };
|
||||
strncpy(colorR, textColor.c_str() + 1, 2);
|
||||
strncpy(colorG, textColor.c_str() + 3, 2);
|
||||
strncpy(colorB, textColor.c_str() + 5, 2);
|
||||
HGUInt r = htoi(colorR);
|
||||
HGUInt g = htoi(colorG);
|
||||
HGUInt b = htoi(colorB);
|
||||
|
||||
int ret = -1;
|
||||
HGImage image = NULL;
|
||||
HGImgFmt_LoadImage(imagePath.c_str(), 0, NULL, 0, HGBASE_IMGORIGIN_TOP, &image);
|
||||
if (NULL != image)
|
||||
{
|
||||
HGImageRoi roi;
|
||||
HGBase_GetImageROI(image, &roi);
|
||||
|
||||
if (HGIMGPROC_WMPOSTYPE_LEFT == posType)
|
||||
{
|
||||
roi.left += marginLeft;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_TOP == posType)
|
||||
{
|
||||
roi.top += marginTop;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_RIGHT == posType)
|
||||
{
|
||||
roi.right -= marginRight;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_BOTTOM == posType)
|
||||
{
|
||||
roi.bottom -= marginBottom;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_LEFTTOP == posType)
|
||||
{
|
||||
roi.left += marginLeft;
|
||||
roi.top += marginTop;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_RIGHTTOP == posType)
|
||||
{
|
||||
roi.top += marginTop;
|
||||
roi.right -= marginRight;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_LEFTBOTTOM == posType)
|
||||
{
|
||||
roi.left += marginLeft;
|
||||
roi.bottom -= marginBottom;
|
||||
}
|
||||
else if (HGIMGPROC_WMPOSTYPE_RIGHTBOTTOM == posType)
|
||||
{
|
||||
roi.right -= marginRight;
|
||||
roi.bottom -= marginBottom;
|
||||
}
|
||||
|
||||
HGImgWatermarkFontParam fontParam;
|
||||
strcpy(fontParam.foneName, fontName.c_str());
|
||||
fontParam.fontSize = fontSize;
|
||||
fontParam.bold = fontBold;
|
||||
fontParam.underline = fontUnderline;
|
||||
fontParam.italic = fontItalic;
|
||||
fontParam.strikeout = fontStrikeout;
|
||||
|
||||
HGColor color = HG_MAKECOLOR(r, g, b, textOpacity);
|
||||
if (HGBASE_ERR_OK == HGBase_SetImageROI(image, &roi)
|
||||
&& HGBASE_ERR_OK == HGImgProc_AddImageWatermark(image, text.c_str(), color, posType,
|
||||
locationX, locationY, &fontParam))
|
||||
{
|
||||
if (0 == SaveImage(image, outImagePath))
|
||||
{
|
||||
HGBase_EnterLock(m_lock);
|
||||
m_saveFilePathList.push_back(outImagePath);
|
||||
RestoreSaveFilePathList(m_saveFilePathList);
|
||||
HGBase_LeaveLock(m_lock);
|
||||
errInfo.clear();
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(image);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ManagerV2::UploadLocalFile(const std::string& filePath, const std::string& remoteFilePath, const std::string& uploadMode,
|
||||
const std::string& httpHost, int httpPort, const std::string& httpPath, const std::string& ftpUser, const std::string& ftpPassword,
|
||||
const std::string& ftpHost, int ftpPort, std::string& errInfo)
|
||||
{
|
||||
errInfo = "错误";
|
||||
|
||||
if (filePath.empty() || remoteFilePath.empty())
|
||||
return -1;
|
||||
if ("http" != mode && "ftp" != mode)
|
||||
if ("http" != uploadMode && "ftp" != uploadMode)
|
||||
return -1;
|
||||
|
||||
int ret = -1;
|
||||
if ("http" == mode)
|
||||
if ("http" == uploadMode)
|
||||
{
|
||||
ret = HttpUpload(m_globalCfg.uploadHttpHost, m_globalCfg.uploadHttpPort, m_globalCfg.uploadHttpPath,
|
||||
filePath, remoteFilePath);
|
||||
ret = HttpUpload(httpHost, httpPort, httpPath, filePath, remoteFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = FtpUpload(m_globalCfg.uploadFtpUser, m_globalCfg.uploadFtpPassword, m_globalCfg.uploadFtpHost,
|
||||
m_globalCfg.uploadFtpPort, filePath, remoteFilePath);
|
||||
ret = FtpUpload(ftpUser, ftpPassword, ftpHost, ftpPort, filePath, remoteFilePath);
|
||||
}
|
||||
|
||||
if (0 == ret)
|
||||
|
@ -2347,6 +2480,29 @@ namespace ver_2
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ManagerV2::ImageAddWatermark(int imageIndex, const std::string& text, const std::string& textColor, int textOpacity, const std::string& textPos,
|
||||
int marginLeft, int marginTop, int marginRight, int marginBottom, int locationX, int locationY, const std::string& fontName,
|
||||
int fontSize, bool fontBold, bool fontUnderline, bool fontItalic, bool fontStrikeout, std::string& outImagePath, std::string& errInfo)
|
||||
{
|
||||
outImagePath.clear();
|
||||
errInfo.clear();
|
||||
|
||||
if (NULL == m_sqlite)
|
||||
return -1;
|
||||
|
||||
std::string imagePath;
|
||||
if (0 != SaveImage(imageIndex, imagePath))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = LocalImageAddWatermark(imagePath, text, textColor, textOpacity, textPos, marginLeft, marginTop, marginRight, marginBottom,
|
||||
locationX, locationY, fontName, fontSize, fontBold, fontUnderline, fontItalic, fontStrikeout, outImagePath, errInfo);
|
||||
|
||||
HGBase_DeleteFile(imagePath.c_str());
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ManagerV2::LoadBase64(const std::string& fileName, std::string& base64)
|
||||
{
|
||||
base64.clear();
|
||||
|
@ -2641,7 +2797,7 @@ namespace ver_2
|
|||
break;
|
||||
#else
|
||||
struct stat buf;
|
||||
int result = stat(lineContent, &buf);
|
||||
int result = stat(filePath, &buf);
|
||||
if (0 != result)
|
||||
break;
|
||||
#endif
|
||||
|
@ -3238,7 +3394,7 @@ namespace ver_2
|
|||
if (NULL == imgData)
|
||||
return NULL;
|
||||
|
||||
size = imgSize;
|
||||
size = (HGUInt)imgSize;
|
||||
format = imgFormat;
|
||||
return imgData;
|
||||
}
|
||||
|
@ -3424,7 +3580,7 @@ namespace ver_2
|
|||
void ManagerV2::ClearBindFolder()
|
||||
{
|
||||
assert(!m_bindFolder.empty());
|
||||
|
||||
#if defined(HG_CMP_MSC)
|
||||
char szFind[MAX_PATH];
|
||||
sprintf(szFind, "%s*.*", m_bindFolder.c_str());
|
||||
|
||||
|
@ -3445,6 +3601,24 @@ namespace ver_2
|
|||
} while (FindNextFileA(hFind, &FindFileData));
|
||||
|
||||
FindClose(hFind);
|
||||
#else
|
||||
DIR* dir = opendir(m_bindFolder.c_str());
|
||||
if (NULL != dir)
|
||||
{
|
||||
struct dirent* dire = NULL;
|
||||
while (dire = readdir(dir))
|
||||
{
|
||||
char fileName[256];
|
||||
sprintf(fileName, "%s%s", m_bindFolder.c_str(), dire->d_name);
|
||||
if (!IS_DIR(fileName))
|
||||
{
|
||||
HGBase_DeleteFile(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ManagerV2::UpdateBindFolder()
|
||||
|
@ -3498,7 +3672,11 @@ namespace ver_2
|
|||
sprintf(fileName, fmt, m_bindFolder.c_str(), m_bindNameBase + tables[i].idx, tables[i].format.c_str());
|
||||
char destName[256];
|
||||
sprintf(destName, fmt, m_bindFolder.c_str(), m_bindNameBase + tables[i].idx + 1, tables[i].format.c_str());
|
||||
#if defined(HG_CMP_MSC)
|
||||
MoveFileA(fileName, destName);
|
||||
#else
|
||||
rename(fileName, destName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3580,7 +3758,11 @@ namespace ver_2
|
|||
sprintf(fileName, fmt, m_bindFolder.c_str(), m_bindNameBase + tables[i].idx, tables[i].format.c_str());
|
||||
char destName[256];
|
||||
sprintf(destName, fmt, m_bindFolder.c_str(), m_bindNameBase + tables[i].idx - value, tables[i].format.c_str());
|
||||
#if defined(HG_CMP_MSC)
|
||||
MoveFileA(fileName, destName);
|
||||
#else
|
||||
rename(fileName, destName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3607,17 +3789,29 @@ namespace ver_2
|
|||
sprintf(fileName1, fmt, m_bindFolder.c_str(), m_bindNameBase + imageIndex1, format1.c_str());
|
||||
char TmpFileName[256];
|
||||
sprintf(TmpFileName, "%sTemp", m_bindFolder.c_str());
|
||||
#if defined(HG_CMP_MSC)
|
||||
MoveFileA(fileName1, TmpFileName);
|
||||
#else
|
||||
rename(fileName1, TmpFileName);
|
||||
#endif
|
||||
|
||||
char fileName2[256];
|
||||
sprintf(fileName2, fmt, m_bindFolder.c_str(), m_bindNameBase + imageIndex2, format2.c_str());
|
||||
char fileName2Dest[256];
|
||||
sprintf(fileName2Dest, fmt, m_bindFolder.c_str(), m_bindNameBase + imageIndex1, format2.c_str());
|
||||
#if defined(HG_CMP_MSC)
|
||||
MoveFileA(fileName2, fileName2Dest);
|
||||
#else
|
||||
rename(fileName2, fileName2Dest);
|
||||
#endif
|
||||
|
||||
char fileName1Dest[256];
|
||||
sprintf(fileName1Dest, fmt, m_bindFolder.c_str(), m_bindNameBase + imageIndex2, format1.c_str());
|
||||
#if defined(HG_CMP_MSC)
|
||||
MoveFileA(TmpFileName, fileName1Dest);
|
||||
#else
|
||||
rename(TmpFileName, fileName1Dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ManagerV2::ClearBindFolderImageList(const std::vector<BatchTableInfo>& tables)
|
||||
|
|
|
@ -36,22 +36,13 @@ namespace ver_2
|
|||
imageFormatMask = 0x00000008,
|
||||
imageJpegQualityMask = 0x00000010,
|
||||
imageTiffCompressionMask = 0x00000020,
|
||||
imageTiffJpegQualityMask = 0x00000040,
|
||||
uploadHttpHostMask = 0x00000080,
|
||||
uploadHttpPortMask = 0x00000100,
|
||||
uploadHttpPathMask = 0x00000200,
|
||||
uploadFtpUserMask = 0x00000400,
|
||||
uploadFtpPasswordMask = 0x00000800,
|
||||
uploadFtpHostMask = 0x00001000,
|
||||
uploadFtpPortMask = 0x00002000,
|
||||
imageTiffJpegQualityMask = 0x00000040
|
||||
};
|
||||
|
||||
GlobalConfig()
|
||||
{
|
||||
imageJpegQuality = 0;
|
||||
imageTiffJpegQuality = 0;
|
||||
uploadHttpPort = 0;
|
||||
uploadFtpPort = 0;
|
||||
}
|
||||
|
||||
// 文件保存
|
||||
|
@ -63,14 +54,6 @@ namespace ver_2
|
|||
int imageJpegQuality;
|
||||
std::string imageTiffCompression;
|
||||
int imageTiffJpegQuality;
|
||||
// 上传
|
||||
std::string uploadHttpHost;
|
||||
unsigned short uploadHttpPort;
|
||||
std::string uploadHttpPath;
|
||||
std::string uploadFtpUser;
|
||||
std::string uploadFtpPassword;
|
||||
std::string uploadFtpHost;
|
||||
unsigned short uploadFtpPort;
|
||||
};
|
||||
|
||||
struct DeviceParam
|
||||
|
@ -229,8 +212,14 @@ namespace ver_2
|
|||
std::string& outZipPath, std::string& errInfo);
|
||||
// 本地图像纠偏
|
||||
int LocalImageDeskew(const std::string& imagePath, std::string& outImagePath, std::string& errInfo);
|
||||
// 本地图像添加水印
|
||||
int LocalImageAddWatermark(const std::string& imagePath, const std::string& text, const std::string& textColor, int textOpacity, const std::string& textPos,
|
||||
int marginLeft, int marginTop, int marginRight, int marginBottom, int locationX, int locationY, const std::string& fontName,
|
||||
int fontSize, bool fontBold, bool fontUnderline, bool fontItalic, bool fontStrikeout, std::string& outImagePath, std::string& errInfo);
|
||||
// 上传文件
|
||||
int UploadLocalFile(const std::string& filePath, const std::string& mode, const std::string& remoteFilePath, std::string& errInfo);
|
||||
int UploadLocalFile(const std::string& filePath, const std::string& remoteFilePath, const std::string& uploadMode,
|
||||
const std::string &httpHost, int httpPort, const std::string& httpPath, const std::string &ftpUser, const std::string& ftpPassword,
|
||||
const std::string& ftpHost, int ftpPort, std::string& errInfo);
|
||||
|
||||
// 设备初始化
|
||||
int InitDevice(std::string& errInfo);
|
||||
|
@ -314,6 +303,10 @@ namespace ver_2
|
|||
int MakeZipFile(const std::vector<int>& imageIndexList, std::string& outZipPath, std::string& errInfo);
|
||||
// 图像纠偏
|
||||
int ImageDeskew(int imageIndex, std::string& outImagePath, std::string& errInfo);
|
||||
// 图像添加水印
|
||||
int ImageAddWatermark(int imageIndex, const std::string& text, const std::string& textColor, int textOpacity, const std::string& textPos,
|
||||
int marginLeft, int marginTop, int marginRight, int marginBottom, int locationX, int locationY, const std::string& fontName,
|
||||
int fontSize, bool fontBold, bool fontUnderline, bool fontItalic, bool fontStrikeout, std::string& outImagePath, std::string& errInfo);
|
||||
|
||||
public:
|
||||
static int LoadBase64(const std::string& fileName, std::string& base64);
|
||||
|
|
|
@ -272,6 +272,10 @@ namespace ver_2
|
|||
{
|
||||
LocalImageDeskew(json);
|
||||
}
|
||||
else if ("local_image_add_watermark" == func)
|
||||
{
|
||||
LocalImageAddWatermark(json);
|
||||
}
|
||||
else if ("upload_local_file" == func)
|
||||
{
|
||||
UploadLocalFile(json);
|
||||
|
@ -424,6 +428,10 @@ namespace ver_2
|
|||
{
|
||||
ImageDeskew(json);
|
||||
}
|
||||
else if ("image_add_watermark" == func)
|
||||
{
|
||||
ImageAddWatermark(json);
|
||||
}
|
||||
|
||||
cJSON_Delete(json);
|
||||
}
|
||||
|
@ -1040,34 +1048,6 @@ namespace ver_2
|
|||
if (find)
|
||||
mask |= GlobalConfig::imageTiffJpegQualityMask;
|
||||
|
||||
cfg.uploadHttpHost = GetJsonStringValue(json, "upload_http_host", &find);
|
||||
if (find)
|
||||
mask |= GlobalConfig::uploadHttpHostMask;
|
||||
|
||||
cfg.uploadHttpPort = GetJsonIntValue(json, "upload_http_port", &find);
|
||||
if (find)
|
||||
mask |= GlobalConfig::uploadHttpPortMask;
|
||||
|
||||
cfg.uploadHttpPath = GetJsonStringValue(json, "upload_http_path", &find);
|
||||
if (find)
|
||||
mask |= GlobalConfig::uploadHttpPathMask;
|
||||
|
||||
cfg.uploadFtpUser = GetJsonStringValue(json, "upload_ftp_user", &find);
|
||||
if (find)
|
||||
mask |= GlobalConfig::uploadFtpUserMask;
|
||||
|
||||
cfg.uploadFtpPassword = GetJsonStringValue(json, "upload_ftp_password", &find);
|
||||
if (find)
|
||||
mask |= GlobalConfig::uploadFtpPasswordMask;
|
||||
|
||||
cfg.uploadFtpHost = GetJsonStringValue(json, "upload_ftp_host", &find);
|
||||
if (find)
|
||||
mask |= GlobalConfig::uploadFtpHostMask;
|
||||
|
||||
cfg.uploadFtpPort = GetJsonIntValue(json, "upload_ftp_port", &find);
|
||||
if (find)
|
||||
mask |= GlobalConfig::uploadFtpPortMask;
|
||||
|
||||
std::string errInfo;
|
||||
int ret = GetManager()->SetGlobalConfig(cfg, mask, errInfo);
|
||||
|
||||
|
@ -1136,14 +1116,7 @@ namespace ver_2
|
|||
fmt += "\"image_format\":\"%s\", ";
|
||||
fmt += "\"image_jpeg_quality\":%d, ";
|
||||
fmt += "\"image_tiff_compression\":\"%s\", ";
|
||||
fmt += "\"image_tiff_jpeg_quality\":%d, ";
|
||||
fmt += "\"upload_http_host\":\"%s\", ";
|
||||
fmt += "\"upload_http_port\":%d, ";
|
||||
fmt += "\"upload_http_path\":\"%s\", ";
|
||||
fmt += "\"upload_ftp_user\":\"%s\", ";
|
||||
fmt += "\"upload_ftp_password\":\"%s\", ";
|
||||
fmt += "\"upload_ftp_host\":\"%s\", ";
|
||||
fmt += "\"upload_ftp_port\":%d}";
|
||||
fmt += "\"image_tiff_jpeg_quality\":%d}";
|
||||
}
|
||||
|
||||
char resp[2048] = {0};
|
||||
|
@ -1159,15 +1132,11 @@ namespace ver_2
|
|||
if (findIden)
|
||||
sprintf(resp, fmt.c_str(), "get_global_config", iden.c_str(), ret, StdStringToUtf8(strToJson(cfg.fileSavePath)).c_str(),
|
||||
StdStringToUtf8(strToJson(cfg.fileNamePrefix)).c_str(), cfg.fileNameMode.c_str(), cfg.imageFormat.c_str(), cfg.imageJpegQuality,
|
||||
cfg.imageTiffCompression.c_str(), cfg.imageTiffJpegQuality, cfg.uploadHttpHost.c_str(), cfg.uploadHttpPort,
|
||||
strToJson(cfg.uploadHttpPath).c_str(), cfg.uploadFtpUser.c_str(), cfg.uploadFtpPassword.c_str(), cfg.uploadFtpHost.c_str(),
|
||||
cfg.uploadFtpPort);
|
||||
cfg.imageTiffCompression.c_str(), cfg.imageTiffJpegQuality);
|
||||
else
|
||||
sprintf(resp, fmt.c_str(), "get_global_config", ret, StdStringToUtf8(strToJson(cfg.fileSavePath)).c_str(),
|
||||
StdStringToUtf8(strToJson(cfg.fileNamePrefix)).c_str(), cfg.fileNameMode.c_str(), cfg.imageFormat.c_str(), cfg.imageJpegQuality,
|
||||
cfg.imageTiffCompression.c_str(), cfg.imageTiffJpegQuality, cfg.uploadHttpHost.c_str(), cfg.uploadHttpPort,
|
||||
strToJson(cfg.uploadHttpPath).c_str(), cfg.uploadFtpUser.c_str(), cfg.uploadFtpPassword.c_str(), cfg.uploadFtpHost.c_str(),
|
||||
cfg.uploadFtpPort);
|
||||
cfg.imageTiffCompression.c_str(), cfg.imageTiffJpegQuality);
|
||||
}
|
||||
|
||||
SendResponse((const HGByte*)resp, (HGUInt)strlen(resp), HGTRUE);
|
||||
|
@ -1801,6 +1770,113 @@ namespace ver_2
|
|||
delete[] resp;
|
||||
}
|
||||
|
||||
void WSUser::LocalImageAddWatermark(cJSON* json)
|
||||
{
|
||||
assert(NULL != json);
|
||||
|
||||
std::string imagePath = Utf8ToStdString(GetJsonStringValue(json, "image_path"));
|
||||
std::string text = Utf8ToStdString(GetJsonStringValue(json, "text"));
|
||||
|
||||
bool find;
|
||||
std::string textColor = GetJsonStringValue(json, "text_color", &find);
|
||||
if (!find)
|
||||
textColor = "#000000";
|
||||
int textOpacity = GetJsonIntValue(json, "text_opacity", &find);
|
||||
if (!find)
|
||||
textOpacity = 255;
|
||||
std::string textPos = GetJsonStringValue(json, "text_pos", &find);
|
||||
if (!find)
|
||||
textPos = "location";
|
||||
int marginLeft = GetJsonIntValue(json, "margin_left", &find);
|
||||
int marginTop = GetJsonIntValue(json, "margin_top", &find);
|
||||
int marginRight = GetJsonIntValue(json, "margin_right", &find);
|
||||
int marginBottom = GetJsonIntValue(json, "margin_bottom", &find);
|
||||
int locationX = GetJsonIntValue(json, "location_x", &find);
|
||||
int locationY = GetJsonIntValue(json, "location_y", &find);
|
||||
|
||||
std::string fontName = Utf8ToStdString(GetJsonStringValue(json, "font_name", &find));
|
||||
if (!find)
|
||||
fontName = "宋体";
|
||||
int fontSize = GetJsonIntValue(json, "font_size", &find);
|
||||
if (!find)
|
||||
fontSize = 20;
|
||||
bool fontBold = GetJsonBoolValue(json, "font_bold");
|
||||
bool fontUnderline = GetJsonBoolValue(json, "font_underline");
|
||||
bool fontItalic = GetJsonBoolValue(json, "font_italic");
|
||||
bool fontStrikeout = GetJsonBoolValue(json, "font_strikeout");
|
||||
|
||||
std::string outImagePath;
|
||||
std::string errInfo;
|
||||
int ret = GetManager()->LocalImageAddWatermark(imagePath, text, textColor, textOpacity, textPos,
|
||||
marginLeft, marginTop, marginRight, marginBottom, locationX, locationY, fontName, fontSize,
|
||||
fontBold, fontUnderline, fontItalic, fontStrikeout, outImagePath, errInfo);
|
||||
|
||||
std::string outImageBase64;
|
||||
bool getBase64 = GetJsonBoolValue(json, "get_base64");
|
||||
if (0 == ret && getBase64)
|
||||
{
|
||||
std::string errInfo2;
|
||||
GetManager()->LoadLocalImage(outImagePath, outImageBase64, errInfo2);
|
||||
}
|
||||
|
||||
bool findIden = false;
|
||||
std::string iden = GetJsonStringValue(json, "iden", &findIden);
|
||||
|
||||
std::string fmt;
|
||||
fmt += "{\"func\":\"%s\", ";
|
||||
if (findIden)
|
||||
fmt += "\"iden\":\"%s\", ";
|
||||
if (0 != ret)
|
||||
{
|
||||
fmt += "\"ret\":%d, ";
|
||||
fmt += "\"err_info\":\"%s\"}";
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt += "\"ret\":%d, ";
|
||||
if (getBase64)
|
||||
{
|
||||
fmt += "\"image_path\":\"%s\", ";
|
||||
fmt += "\"image_base64\":\"%s\"}";
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt += "\"image_path\":\"%s\"}";
|
||||
}
|
||||
}
|
||||
|
||||
char* resp = new char[1024 + outImageBase64.size()];
|
||||
if (0 != ret)
|
||||
{
|
||||
if (findIden)
|
||||
sprintf(resp, fmt.c_str(), "local_image_add_watermark", iden.c_str(), ret, StdStringToUtf8(errInfo).c_str());
|
||||
else
|
||||
sprintf(resp, fmt.c_str(), "local_image_add_watermark", ret, StdStringToUtf8(errInfo).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (findIden)
|
||||
{
|
||||
if (getBase64)
|
||||
sprintf(resp, fmt.c_str(), "local_image_add_watermark", iden.c_str(), ret, StdStringToUtf8(strToJson(outImagePath)).c_str(),
|
||||
outImageBase64.c_str());
|
||||
else
|
||||
sprintf(resp, fmt.c_str(), "local_image_add_watermark", iden.c_str(), ret, StdStringToUtf8(strToJson(outImagePath)).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getBase64)
|
||||
sprintf(resp, fmt.c_str(), "local_image_add_watermark", ret, StdStringToUtf8(strToJson(outImagePath)).c_str(),
|
||||
outImageBase64.c_str());
|
||||
else
|
||||
sprintf(resp, fmt.c_str(), "local_image_add_watermark", ret, StdStringToUtf8(strToJson(outImagePath)).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
SendResponse((const HGByte*)resp, (HGUInt)strlen(resp), HGTRUE);
|
||||
delete[] resp;
|
||||
}
|
||||
|
||||
void WSUser::UploadLocalFile(cJSON* json)
|
||||
{
|
||||
assert(NULL != json);
|
||||
|
@ -1808,9 +1884,6 @@ namespace ver_2
|
|||
std::string filePath = Utf8ToStdString(GetJsonStringValue(json, "file_path"));
|
||||
|
||||
bool find = false;
|
||||
std::string mode = GetJsonStringValue(json, "upload_mode", &find);
|
||||
if (!find)
|
||||
mode = "http";
|
||||
std::string remoteFilePath = Utf8ToStdString(GetJsonStringValue(json, "remote_file_path", &find));
|
||||
if (!find)
|
||||
{
|
||||
|
@ -1820,9 +1893,26 @@ namespace ver_2
|
|||
remoteFilePath += "/";
|
||||
remoteFilePath += fileName;
|
||||
}
|
||||
std::string uploadMode = GetJsonStringValue(json, "upload_mode", &find);
|
||||
if (!find)
|
||||
uploadMode = "http";
|
||||
std::string httpHost = GetJsonStringValue(json, "http_host", &find);
|
||||
int httpPort = GetJsonIntValue(json, "http_port", &find);
|
||||
if (!find)
|
||||
httpPort = 80;
|
||||
std::string httpPath = GetJsonStringValue(json, "http_path", &find);
|
||||
if (!find)
|
||||
httpPath = "/upload.cgi";
|
||||
std::string ftpUser = GetJsonStringValue(json, "ftp_user", &find);
|
||||
std::string ftpPassword = GetJsonStringValue(json, "ftp_password", &find);
|
||||
std::string ftpHost = GetJsonStringValue(json, "ftp_host", &find);
|
||||
int ftpPort = GetJsonIntValue(json, "ftp_port", &find);
|
||||
if (!find)
|
||||
ftpPort = 21;
|
||||
|
||||
std::string errInfo;
|
||||
int ret = GetManager()->UploadLocalFile(filePath, mode, remoteFilePath, errInfo);
|
||||
int ret = GetManager()->UploadLocalFile(filePath, remoteFilePath, uploadMode, httpHost, httpPort, httpPath,
|
||||
ftpUser, ftpPassword, ftpHost, ftpPort, errInfo);
|
||||
|
||||
bool findIden = false;
|
||||
std::string iden = GetJsonStringValue(json, "iden", &findIden);
|
||||
|
@ -4033,4 +4123,111 @@ namespace ver_2
|
|||
SendResponse((const HGByte*)resp, (HGUInt)strlen(resp), HGTRUE);
|
||||
delete[] resp;
|
||||
}
|
||||
|
||||
void WSUser::ImageAddWatermark(cJSON* json)
|
||||
{
|
||||
assert(NULL != json);
|
||||
|
||||
int imageIndex = GetJsonIntValue(json, "image_index");
|
||||
std::string text = Utf8ToStdString(GetJsonStringValue(json, "text"));
|
||||
|
||||
bool find;
|
||||
std::string textColor = GetJsonStringValue(json, "text_color", &find);
|
||||
if (!find)
|
||||
textColor = "#000000";
|
||||
int textOpacity = GetJsonIntValue(json, "text_opacity", &find);
|
||||
if (!find)
|
||||
textOpacity = 255;
|
||||
std::string textPos = GetJsonStringValue(json, "text_pos", &find);
|
||||
if (!find)
|
||||
textPos = "location";
|
||||
int marginLeft = GetJsonIntValue(json, "margin_left", &find);
|
||||
int marginTop = GetJsonIntValue(json, "margin_top", &find);
|
||||
int marginRight = GetJsonIntValue(json, "margin_right", &find);
|
||||
int marginBottom = GetJsonIntValue(json, "margin_bottom", &find);
|
||||
int locationX = GetJsonIntValue(json, "location_x", &find);
|
||||
int locationY = GetJsonIntValue(json, "location_y", &find);
|
||||
|
||||
std::string fontName = Utf8ToStdString(GetJsonStringValue(json, "font_name", &find));
|
||||
if (!find)
|
||||
fontName = "宋体";
|
||||
int fontSize = GetJsonIntValue(json, "font_size", &find);
|
||||
if (!find)
|
||||
fontSize = 20;
|
||||
bool fontBold = GetJsonBoolValue(json, "font_bold");
|
||||
bool fontUnderline = GetJsonBoolValue(json, "font_underline");
|
||||
bool fontItalic = GetJsonBoolValue(json, "font_italic");
|
||||
bool fontStrikeout = GetJsonBoolValue(json, "font_strikeout");
|
||||
|
||||
std::string outImagePath;
|
||||
std::string errInfo;
|
||||
int ret = GetManager()->ImageAddWatermark(imageIndex, text, textColor, textOpacity, textPos,
|
||||
marginLeft, marginTop, marginRight, marginBottom, locationX, locationY, fontName, fontSize,
|
||||
fontBold, fontUnderline, fontItalic, fontStrikeout, outImagePath, errInfo);
|
||||
|
||||
std::string outImageBase64;
|
||||
bool getBase64 = GetJsonBoolValue(json, "get_base64");
|
||||
if (0 == ret && getBase64)
|
||||
{
|
||||
std::string errInfo2;
|
||||
GetManager()->LoadLocalImage(outImagePath, outImageBase64, errInfo2);
|
||||
}
|
||||
|
||||
bool findIden = false;
|
||||
std::string iden = GetJsonStringValue(json, "iden", &findIden);
|
||||
|
||||
std::string fmt;
|
||||
fmt += "{\"func\":\"%s\", ";
|
||||
if (findIden)
|
||||
fmt += "\"iden\":\"%s\", ";
|
||||
if (0 != ret)
|
||||
{
|
||||
fmt += "\"ret\":%d, ";
|
||||
fmt += "\"err_info\":\"%s\"}";
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt += "\"ret\":%d, ";
|
||||
if (getBase64)
|
||||
{
|
||||
fmt += "\"image_path\":\"%s\", ";
|
||||
fmt += "\"image_base64\":\"%s\"}";
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt += "\"image_path\":\"%s\"}";
|
||||
}
|
||||
}
|
||||
|
||||
char* resp = new char[1024 + outImageBase64.size()];
|
||||
if (0 != ret)
|
||||
{
|
||||
if (findIden)
|
||||
sprintf(resp, fmt.c_str(), "image_add_watermark", iden.c_str(), ret, StdStringToUtf8(errInfo).c_str());
|
||||
else
|
||||
sprintf(resp, fmt.c_str(), "image_add_watermark", ret, StdStringToUtf8(errInfo).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (findIden)
|
||||
{
|
||||
if (getBase64)
|
||||
sprintf(resp, fmt.c_str(), "image_add_watermark", iden.c_str(), ret, StdStringToUtf8(strToJson(outImagePath)).c_str(),
|
||||
outImageBase64.c_str());
|
||||
else
|
||||
sprintf(resp, fmt.c_str(), "image_add_watermark", iden.c_str(), ret, StdStringToUtf8(strToJson(outImagePath)).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getBase64)
|
||||
sprintf(resp, fmt.c_str(), "image_add_watermark", ret, StdStringToUtf8(strToJson(outImagePath)).c_str(),
|
||||
outImageBase64.c_str());
|
||||
else
|
||||
sprintf(resp, fmt.c_str(), "image_add_watermark", ret, StdStringToUtf8(strToJson(outImagePath)).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
SendResponse((const HGByte*)resp, (HGUInt)strlen(resp), HGTRUE);
|
||||
delete[] resp;
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ namespace ver_2
|
|||
void SplitLocalImage(cJSON* json);
|
||||
void LocalMakeZipFile(cJSON* json);
|
||||
void LocalImageDeskew(cJSON* json);
|
||||
void LocalImageAddWatermark(cJSON* json);
|
||||
void UploadLocalFile(cJSON* json);
|
||||
|
||||
void InitDevice(cJSON* json);
|
||||
|
@ -84,6 +85,7 @@ namespace ver_2
|
|||
void SplitImage(cJSON* json);
|
||||
void MakeZipFile(cJSON* json);
|
||||
void ImageDeskew(cJSON* json);
|
||||
void ImageAddWatermark(cJSON* json);
|
||||
|
||||
private:
|
||||
std::string m_initDeviceIden;
|
||||
|
|
|
@ -71,6 +71,11 @@
|
|||
var myCanvas = document.getElementById("myCanvas");
|
||||
myCanvas.src = message['image_base64'];
|
||||
}
|
||||
else if ("local_image_add_watermark" == message['func'])
|
||||
{
|
||||
var myCanvas = document.getElementById("myCanvas");
|
||||
myCanvas.src = message['image_base64'];
|
||||
}
|
||||
else if ("upload_local_file" == message['func'])
|
||||
{
|
||||
alert(msg.data);
|
||||
|
@ -264,6 +269,11 @@
|
|||
var myCanvas = document.getElementById("myCanvas");
|
||||
myCanvas.src = message['image_base64'];
|
||||
}
|
||||
else if ("image_add_watermark" == message['func'])
|
||||
{
|
||||
var myCanvas = document.getElementById("myCanvas");
|
||||
myCanvas.src = message['image_base64'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -354,6 +364,25 @@
|
|||
}));
|
||||
}
|
||||
|
||||
function LocalImageAddWatermark()
|
||||
{
|
||||
socket.send(JSON.stringify({
|
||||
'func':'local_image_add_watermark',
|
||||
'image_path':'D:\\1.jpg',
|
||||
'text':'扫描仪,1234qwer',
|
||||
'text_color':'#FF0000',
|
||||
'text_pos':'right_top',
|
||||
'font_size':60,
|
||||
'margin_right':20,
|
||||
'margin_top':50,
|
||||
'font_bold':true,
|
||||
'font_underline':true,
|
||||
'font_italic':true,
|
||||
'font_strikeout':true,
|
||||
'get_base64':true
|
||||
}));
|
||||
}
|
||||
|
||||
function UploadLocalFile()
|
||||
{
|
||||
socket.send(JSON.stringify({
|
||||
|
@ -648,6 +677,18 @@
|
|||
}));
|
||||
}
|
||||
|
||||
function ImageAddWatermark()
|
||||
{
|
||||
socket.send(JSON.stringify({
|
||||
'func':'image_add_watermark',
|
||||
'image_index':0,
|
||||
'text':'1234567890',
|
||||
'text_color':'#FF0000',
|
||||
'font_size':60,
|
||||
'get_base64':true
|
||||
}));
|
||||
}
|
||||
|
||||
window.onload = function()
|
||||
{
|
||||
var myimg = document.getElementById("myCanvas");
|
||||
|
@ -686,6 +727,7 @@
|
|||
<input type="button" value="拆分本地图像" onclick="SplitLocalImage()" />
|
||||
<input type="button" value="本地生成压缩文件" onclick="LocalMakeZipFile()" />
|
||||
<input type="button" value="本地图像纠偏" onclick="LocalImageDeskew()" />
|
||||
<input type="button" value="本地图像添加水印" onclick="LocalImageAddWatermark()" />
|
||||
<input type="button" value="上传本地文件" onclick="UploadLocalFile()" />
|
||||
<input type="button" value="初始化设备" onclick="InitDevice()" />
|
||||
<input type="button" value="反初始化设备" onclick="DeinitDevice()" />
|
||||
|
@ -722,6 +764,7 @@
|
|||
<input type="button" value="拆分图像" onclick="SplitImage()" />
|
||||
<input type="button" value="生成压缩文件" onclick="MakeZipFile()" />
|
||||
<input type="button" value="图像纠偏" onclick="ImageDeskew()" />
|
||||
<input type="button" value="图像添加水印" onclick="ImageAddWatermark()" />
|
||||
<br />
|
||||
<br />
|
||||
<img id="myCanvas" width='640' height='480' style="background-color: black; float: left;"/>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue