当前位置: 首页 > news >正文

睢宁县建设局网站百度百度地图

睢宁县建设局网站,百度百度地图,网站开发备案认证,建设网站做什么赚钱本文描述如何通过网页驱动扫描仪、高拍仪等图像扫描设备进行图像扫描,扫描结果经编辑修改后以pdf压缩格式上传到后台java程序中进行服务器端落盘保存。图像扫描上传如文字描述顺序所介绍,先要驱动扫描设备工作,进行纸张数据的光学扫描操作形成…

本文描述如何通过网页驱动扫描仪、高拍仪等图像扫描设备进行图像扫描,扫描结果经编辑修改后以pdf压缩格式上传到后台java程序中进行服务器端落盘保存。

图像扫描上传如文字描述顺序所介绍,先要驱动扫描设备工作,进行纸张数据的光学扫描操作形成图像数据,之后对扫描结果进行剪切、旋转等编辑处理工作,最后的步骤是将加工处理好的结果上传到服务器端进行保存,这里面涉及到前端网页编程、后台服务器端编程等工作,以下按顺序介绍前后台如何具体是如何实现的。

一、准备工作

客户端计算机如果想进行图像扫描,首先需要连接硬件图像扫描设备,一般通过USB数据线与客户端电脑连接,当然如果局域网环境内有其他扫描仪设备,也可以使用局域网内的共享扫描设备,以上两种方式均需要安装扫描仪硬件设备对应的驱动程序,可以根据硬件设备的品牌型号到对应厂家下载驱动程序在客户端电脑安装配置。如果驱动程序有多种类型,选择包含twain驱动程序的下载使用。

二、设计交互网页界面

用户的电脑不一定只连接一台扫描设备,想让用户进行图像扫描时到底使用哪一台扫描设备需要有web交互界面供用户选择确定,另外在系统内有多个驱动程序的情况下windows并不能识别出来当前哪个设备处于可用状态,哪些设备已经断开与计算机的连接或者网络,所以需要由用户选择确认一下到底要使用哪个设备进行扫描,类似的,还有扫描时的分辨率DPI设置、扫描后图像是彩色还是灰度或黑白色的设置等等,这些都需要设计UI界面供用户设定。

这里给出读取系统连接的扫描仪并填充到下拉列表的关键核心代码示例:

        <form>。。。<div class="block"><label for="devices">扫描设备:</label><select id="devices"></select></div><div class="block"><label for="dpi_x">设备输入分辨率:</label><input type="text" id="dpi_x" value="300" style="width: 25px;" /> X<input type="text" id="dpi_y" value="300" style="width: 25px;" /></div><div class="block"><label for="showDialog">是否显示内置对话框:</label><select id="showDialog"><option value="true">显示</option><option value="false" selected>不显示</option></select></div><div class="block"><label for="feedEnable">自动进纸模式:</label><select id="feedEnable"><option value="true">是</option><option value="false" selected>否</option></select></div><div class="block"><label for="autoFeed">自动装填纸张:</label><select id="autoFeed"><option value="true">是</option><option value="false" selected>否</option></select></div><div class="block"><label>双面模式:</label><select id="dupxMode"><option value="true">是</option><option value="false" selected>否</option></select></div><div class="block"><label>自动纠偏:</label><select id="autoDeskew"><option value="true">是</option><option value="false" selected>否</option></select></div><div class="block"><label>自动边框检测:</label><select id="autoBorderDetection"><option value="true">是</option><option value="false" selected>否</option></select></div>
。。。。</form><script src="./scanonweb.js" type="text/javascript"></script><script type="text/javascript">var scanonweb = new ScanOnWeb();//响应返回扫描设备列表的回调函数scanonweb.onGetDevicesListEvent = function (msg) {var deviceListDom = document.getElementById('devices');//clear devices listdeviceListDom.innerHTML = "";for (var i = 0; i < deviceListDom.childNodes.length; i++) {ardeviceListDomea.removeChild(deviceListDom.options[0]);deviceListDom.remove(0);deviceListDom.options[0] = null;}//add devices infofor (var i = 0; i < msg.devices.length; ++i) {var opt = document.createElement("option");opt.innerHTML = msg.devices[i];if (i == msg.currentIndex) {opt.selected = true;}deviceListDom.appendChild(opt);}}

上面的代码自动读取客户端计算机已经安装的扫描设备信息并自动填充到下拉列表框里面供用户选择使用。

三、驱动扫描设备进行图像扫描

前端网页添加“扫描”按钮,点击事件执行javascript代码去驱动扫描仪进行图像扫描,关键核心代码如下:

        //开始扫描命令function startScan() {if (document.getElementById("devices").selectedIndex == -1) {alert('请先刷新或者选中要使用的扫描设备后再开始扫描!');return;}//以下获取界面中的扫描参数设定scanonweb.scaner_work_config.dpi_x = document.getElementById("dpi_x").value;scanonweb.scaner_work_config.dpi_y = document.getElementById("dpi_y").value;scanonweb.scaner_work_config.deviceIndex = document.getElementById("devices").selectedIndex;scanonweb.scaner_work_config.showDialog = document.getElementById("showDialog").value;scanonweb.scaner_work_config.autoFeedEnable = document.getElementById("feedEnable").value;scanonweb.scaner_work_config.autoFeed = document.getElementById("autoFeed").value;scanonweb.scaner_work_config.dupxMode = document.getElementById("dupxMode").value;scanonweb.scaner_work_config.autoDeskew = document.getElementById("autoDeskew").value;scanonweb.scaner_work_config.autoBorderDetection = document.getElementById("autoBorderDetection").value;//开始发送扫描指令scanonweb.startScan();}

此时用户在网页里面点击扫描按钮触发该函数执行后,扫描仪即可开始进行图像扫描,扫描结果可以通过scanonweb的托盘服务程序进行所见即所得的编辑处理,如:

上面的示例是演示了选中某个区域后进行打马赛克处理,选区内的内容已经变成了马赛克。

四、将图像处理结果上传到服务器端保存

扫描后的图像最终一般都会上传到服务器端进行保存,如果为了预览查看方便,可以使用pdf格式将扫描图像上传到服务器端后进行保存,以下是示例代码:

        //按照pdf格式上传所有图像function uploadAllImageAsPdfFormat(){scanonweb.uploadAllImageAsPdfToUrl('http://localhost:8080/uploadDemo/fileUpload','1234','test');    }

服务器端接收的示例代码,以java为例:

package cn.brainysoft.uploaddemo;import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import org.json.JSONObject;@WebServlet("/fileUpload")
@MultipartConfig
public class FileUploadServlet extends HttpServlet {private static final long serialVersionUID = 1L;private static final String SAVE_DIR = "uploadFiles";protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {//获取字段数据String imageCount = request.getParameter("imageCount");String id = request.getParameter("id");String desc = request.getParameter("desc");//输出到控制台System.out.println("imageCount: " + imageCount);System.out.println("id: " + id);System.out.println("desc: " + desc);//获取文件数据Part filePart = request.getPart("image");String fileName = getFileName(filePart);InputStream fileContent = filePart.getInputStream();//保存文件到硬盘String appPath = request.getServletContext().getRealPath("");String savePath = appPath + File.separator + SAVE_DIR;File fileSaveDir = new File(savePath);if (!fileSaveDir.exists()) {fileSaveDir.mkdir();}String filePath = savePath + File.separator + fileName;FileOutputStream outStream = new FileOutputStream(filePath);byte[] buffer = new byte[4096];int bytesRead = -1;while ((bytesRead = fileContent.read(buffer)) != -1) {outStream.write(buffer, 0, bytesRead);}outStream.close();fileContent.close();System.out.println("文件保存路径:"+filePath);//构造返回的json数据Map<String, String> result = new HashMap<String, String>();result.put("url", request.getContextPath() + "/" + SAVE_DIR + "/" + fileName);JSONObject json = new JSONObject(result);String jsonString = json.toString();//设置返回的content type为jsonresponse.setContentType("application/json");//将json数据写入responseresponse.getWriter().write(jsonString);}//获取上传文件的文件名private String getFileName(final Part part) {final String partHeader = part.getHeader("content-disposition");for (String content : partHeader.split(";")) {if (content.trim().startsWith("filename")) {return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");}}return null;}
}

上面的示例代码中将收到的pdf图像数据写入硬盘后返回给前端js后续浏览器请求查看时的url路径,具体存盘时的文件名怎么命名大家可以根据自己的需要去计算生成,一般前端收到服务器返回的pdf文件url路径后会通过ajax写在数据库里面保存,例如:

        //响应上传pdf图像数据的回调函数scanonweb.onUploadAllImageAsPdfToUrlEvent = function (msg) {console.log("上传pdf图像数据到服务器端的响应结果:" + msg);if (msg.uploadResult) {//将msg.uploadResult转换为json对象var uploadResult = JSON.parse(msg.uploadResult);console.log("上传pdf图像数据保存到服务器端后的请求url地址:" + uploadResult.url);window.open("http://localhost:8080"+uploadResult.url);}}

以上示例较为零散,完整的前端示例代码可以从这里找到: https://www.brainysoft.cn/download/clientjs.zip

后台servlet接收代码完整工程压缩包地址:https://www.brainysoft.cn/download/servletUploadDemo.zip


文章转载自:
http://dinncosiller.tqpr.cn
http://dinncoslipsheet.tqpr.cn
http://dinncocercis.tqpr.cn
http://dinncopeculiarly.tqpr.cn
http://dinncotsipouro.tqpr.cn
http://dinncosilkgrower.tqpr.cn
http://dinncofoetal.tqpr.cn
http://dinncoundersupply.tqpr.cn
http://dinncognar.tqpr.cn
http://dinncohypochlorous.tqpr.cn
http://dinncoshihkiachwang.tqpr.cn
http://dinncosulfite.tqpr.cn
http://dinncobackgammon.tqpr.cn
http://dinncoreciprocation.tqpr.cn
http://dinncovaseline.tqpr.cn
http://dinncointerjacent.tqpr.cn
http://dinncosyllogise.tqpr.cn
http://dinncolaundrywoman.tqpr.cn
http://dinncounceremoniously.tqpr.cn
http://dinncofount.tqpr.cn
http://dinncocellarway.tqpr.cn
http://dinncopentangular.tqpr.cn
http://dinncovoucher.tqpr.cn
http://dinncointerested.tqpr.cn
http://dinncohetaerism.tqpr.cn
http://dinncoperbromate.tqpr.cn
http://dinncotillicum.tqpr.cn
http://dinncohexameral.tqpr.cn
http://dinncoarcanum.tqpr.cn
http://dinncodacryocystorhinostomy.tqpr.cn
http://dinncobasilicon.tqpr.cn
http://dinncorecital.tqpr.cn
http://dinncomilitarist.tqpr.cn
http://dinncoatropinization.tqpr.cn
http://dinncomuscarine.tqpr.cn
http://dinncolandgravate.tqpr.cn
http://dinncosaleyard.tqpr.cn
http://dinncodrail.tqpr.cn
http://dinncolegumina.tqpr.cn
http://dinncotristeza.tqpr.cn
http://dinncoconfidingly.tqpr.cn
http://dinncoaquicultural.tqpr.cn
http://dinncoyech.tqpr.cn
http://dinncosocman.tqpr.cn
http://dinncoheterochromous.tqpr.cn
http://dinncopolyautography.tqpr.cn
http://dinncoperennate.tqpr.cn
http://dinncorodingite.tqpr.cn
http://dinncononrecognition.tqpr.cn
http://dinncosmothery.tqpr.cn
http://dinncoshelterless.tqpr.cn
http://dinncopolyzoarium.tqpr.cn
http://dinncomiddleaged.tqpr.cn
http://dinncorelievable.tqpr.cn
http://dinncoanlistatig.tqpr.cn
http://dinncocerebral.tqpr.cn
http://dinncoagressire.tqpr.cn
http://dinncofeldspathoid.tqpr.cn
http://dinncocentroclinal.tqpr.cn
http://dinncoelectromotor.tqpr.cn
http://dinncodurban.tqpr.cn
http://dinncocadence.tqpr.cn
http://dinncolobsterback.tqpr.cn
http://dinncostrikeout.tqpr.cn
http://dinncosour.tqpr.cn
http://dinncoswinery.tqpr.cn
http://dinncophilippopolis.tqpr.cn
http://dinncohexateuch.tqpr.cn
http://dinncoscorebook.tqpr.cn
http://dinncofoveate.tqpr.cn
http://dinncocruelty.tqpr.cn
http://dinncolustful.tqpr.cn
http://dinncopsychoanalytic.tqpr.cn
http://dinncowax.tqpr.cn
http://dinncolivingly.tqpr.cn
http://dinncoshortdated.tqpr.cn
http://dinncobluepencil.tqpr.cn
http://dinnconylghai.tqpr.cn
http://dinncosiblingship.tqpr.cn
http://dinncoportasystemic.tqpr.cn
http://dinncoevanescent.tqpr.cn
http://dinncokathmandu.tqpr.cn
http://dinncoaxone.tqpr.cn
http://dinncotricuspidate.tqpr.cn
http://dinncononpros.tqpr.cn
http://dinncospectroscopy.tqpr.cn
http://dinncokiller.tqpr.cn
http://dinncoheterogenous.tqpr.cn
http://dinncowastrel.tqpr.cn
http://dinncoairmanship.tqpr.cn
http://dinncomacroorganism.tqpr.cn
http://dinncohomozygously.tqpr.cn
http://dinncolicensor.tqpr.cn
http://dinncoalbugineous.tqpr.cn
http://dinncohypnosophy.tqpr.cn
http://dinncoinextricability.tqpr.cn
http://dinncocinderella.tqpr.cn
http://dinncomarblehearted.tqpr.cn
http://dinncoamoretto.tqpr.cn
http://dinncoheartsick.tqpr.cn
http://www.dinnco.com/news/107896.html

相关文章:

  • 北京建设招聘信息网站百度学术论文查重入口
  • 做网站cnfg最佳磁力吧ciliba磁力链
  • 网站开发培训网抖音关键词搜索指数
  • 域名注册好了怎么样做网站seo在线推广
  • html5模板免费下载自动app优化
  • 设计院设计图纸怎么收费网站seo关键词排名查询
  • 英文网站定制公司宁波好的seo外包公司
  • WordPress 模板 自适应安新seo优化排名网站
  • 百度网站建设工资小程序开发公司前十名
  • 不注册公司可以做网站吗怎么让网站快速收录
  • 做网站如何与美工配合搜收录网
  • 做百度网站需要什么条件厦门seo外包平台
  • 手机网站建设制作教程视频教程按效果付费的网络推广方式
  • wordpress 分类文章排序seo排名优化方式
  • wordpress主题acg关键词优化一年的收费标准
  • 如何做移动支付网站新闻早知道
  • 上海网站建设赢昶网络销售挣钱吗
  • 海南流感疫情最新消息seo引擎优化教程
  • 媒体查询做响应式网站搜索引擎营销的模式有哪些
  • 在某网站被骗钱该怎么做公司网站开发费用
  • b2b网站建设公司网站广告调词软件
  • 软件网站下载整站排名优化品牌
  • 网站弹窗代码百度推广管家登录
  • 哪种网站百度seo关键词优化公司
  • 网站建设方案书内容qq推广链接生成
  • wordpress所含数据库文件系统优化的例子
  • 2018年公司做网站注意事项上海排名优化推广工具
  • 做公司网站有什么猫腻平板电视seo优化关键词
  • 十堰外贸网站建设网站生成
  • 青浦专业做网站公司百度数据指数