From 7fa2e7872cab8f957dcbf5d3788a1fb152ac8d75 Mon Sep 17 00:00:00 2001 From: luoliangyi <87842688@qq.com> Date: Wed, 16 Oct 2024 17:35:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84webscan=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=AE=BE=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/webscan/WebUser.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/sdk/webscan/WebUser.cpp b/sdk/webscan/WebUser.cpp index 3df31de1..4e7bdd85 100644 --- a/sdk/webscan/WebUser.cpp +++ b/sdk/webscan/WebUser.cpp @@ -858,7 +858,7 @@ void WebUser::GetSettingInfoNew(const std::string& devName) AddOptItem(optJson, arrayJson, "fileprefix", m_fileprefix.c_str(), NULL); const char* deleteFileBeforeScanList[] = { "0", "1", NULL }; AddOptItem(optJson, arrayJson, "deletefilesbeforescan", m_deletefilesbeforescan.c_str(), deleteFileBeforeScanList); - const char* fileTypeList[] = { "1", "2", "3", "4", "5", "6", "7", NULL }; + const char* fileTypeList[] = { "1", "2", "3", "4", "6", NULL }; AddOptItem(optJson, arrayJson, "filetype", m_filetype.c_str(), fileTypeList); const char* showBase64List[] = { "0", "1", NULL }; AddOptItem(optJson, arrayJson, "showbase64", m_showbase64.c_str(), showBase64List); @@ -866,7 +866,8 @@ void WebUser::GetSettingInfoNew(const std::string& devName) AddOptItem(optJson, arrayJson, "source", m_source.c_str(), sourceList); const char* modeList[] = { "Lineart", "Gray", "Color", NULL }; AddOptItem(optJson, arrayJson, "mode", m_mode.c_str(), modeList); - AddOptItem(optJson, arrayJson, "resolution", m_resolution.c_str(), NULL); + const char* resolutionList[] = { "100", "200", "300", NULL }; + AddOptItem(optJson, arrayJson, "resolution", m_resolution.c_str(), resolutionList); } cJSON_AddItemToObject(optListJson, "Options", arrayJson); @@ -1587,12 +1588,24 @@ int WebUser::sane_ex_callback(SANE_Handle hdev, int code, void* data, unsigned i if (sane_img->header.format == SANE_FRAME_GRAY) { if (1 == sane_img->header.depth) + { imgType = HGBASE_IMGTYPE_BINARY; + if (2 == atoi(p->m_filetype.c_str())) + p->m_filesuffix = "pbm"; + } else if (8 == sane_img->header.depth) + { imgType = HGBASE_IMGTYPE_GRAY; + if (2 == atoi(p->m_filetype.c_str())) + p->m_filesuffix = "pgm"; + } } else if (sane_img->header.format == SANE_FRAME_RGB) + { imgType = HGBASE_IMGTYPE_RGB; + if (2 == atoi(p->m_filetype.c_str())) + p->m_filesuffix = "ppm"; + } HGByte* data = sane_img->data; HGImageInfo imgInfo = { (HGUInt)sane_img->header.pixels_per_line, (HGUInt)sane_img->header.lines, @@ -1785,9 +1798,9 @@ std::string WebUser::GetBase64(const std::string& filePath) else if (HGIMGFMT_TYPE_TIFF == imgType) prefix = "data:image/tiff;base64,"; else if (HGIMGFMT_TYPE_PDF == imgType) - prefix = "data:image/pdf;base64,"; - else if (HGIMGFMT_TYPE_OFD == imgType) - prefix = "data:image/ofd;base64,"; + prefix = "data:application/pdf;base64,"; + else if (HGIMGFMT_TYPE_PNM == imgType) + prefix = "data:image/pnm;base64,"; base64.insert(0, prefix); } @@ -1902,21 +1915,17 @@ void WebUser::SetParam() } if (1 == atoi(m_filetype.c_str())) - m_filesuffix = "bmp"; - else if (2 == atoi(m_filetype.c_str())) - m_filesuffix = "png"; - else if (4 == atoi(m_filetype.c_str())) m_filesuffix = "tif"; - else if (5 == atoi(m_filetype.c_str())) - m_filesuffix = "gif"; + else if (2 == atoi(m_filetype.c_str())) + m_filesuffix = "ppm"; + else if (4 == atoi(m_filetype.c_str())) + m_filesuffix = "png"; else if (6 == atoi(m_filetype.c_str())) m_filesuffix = "pdf"; - else if (7 == atoi(m_filetype.c_str())) - m_filesuffix = "ofd"; else m_filesuffix = "jpg"; - if ("tif" == m_filesuffix || "pdf" == m_filesuffix || "ofd" == m_filesuffix) + if ("tif" == m_filesuffix || "pdf" == m_filesuffix) { HGBase_CreateDir(m_filepath.c_str()); HGChar fileName[256];