久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

java掃描儀接收代碼,java掃描器代碼

用Java直接從掃描儀獲得掃描數(shù)據(jù),然后上載到服務(wù)器上,這樣的程序需要利用那些知識(shí)點(diǎn)(有關(guān)Java)?

package edu.ctgu.JTwacker;

創(chuàng)新互聯(lián)建站是一家網(wǎng)站設(shè)計(jì)公司,集創(chuàng)意、互聯(lián)網(wǎng)應(yīng)用、軟件技術(shù)為一體的創(chuàng)意網(wǎng)站建設(shè)服務(wù)商,主營(yíng)產(chǎn)品:響應(yīng)式網(wǎng)站設(shè)計(jì)品牌網(wǎng)站制作、成都營(yíng)銷網(wǎng)站建設(shè)。我們專注企業(yè)品牌在網(wǎng)站中的整體樹立,網(wǎng)絡(luò)互動(dòng)的體驗(yàn),以及在手機(jī)等移動(dòng)端的優(yōu)質(zhì)呈現(xiàn)。成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、移動(dòng)互聯(lián)產(chǎn)品、網(wǎng)絡(luò)運(yùn)營(yíng)、VI設(shè)計(jì)、云產(chǎn)品.運(yùn)維為核心業(yè)務(wù)。為用戶提供一站式解決方案,我們深知市場(chǎng)的競(jìng)爭(zhēng)激烈,認(rèn)真對(duì)待每位客戶,為客戶提供賞析悅目的作品,網(wǎng)站的價(jià)值服務(wù)。

import java.awt.BorderLayout;

import java.awt.Cursor;

import java.awt.Dimension;

import java.awt.Graphics;

import java.awt.Rectangle;

import java.awt.Toolkit;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.awt.event.WindowListener;

import java.awt.image.BufferedImage;

import java.io.File;

import java.io.FileInputStream;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JToolBar;

import javax.swing.SwingUtilities;

import com.sun.image.codec.jpeg.JPEGCodec;

import com.sun.image.codec.jpeg.JPEGImageDecoder;

import edu.ctgu.twain.JTwain;

/*

這是顯示掃描圖片的frame

*/

public class JTwacker extends JFrame {

class JPEGPanel extends JPanel {

/** Image for the inner class

*/

protected BufferedImage mJPEGPanelBufferedImage;

/** Pnale to diaply the image

*/

public JPEGPanel() {

// no op

}

/** Sets the bufferedimage into the class

* @param bi BufferedImage

*/

public void setBufferedImage(BufferedImage bi) {

if (bi == null) {

return;

}

mJPEGPanelBufferedImage = bi;

Dimension d = new Dimension(mJPEGPanelBufferedImage.getWidth(this),

mJPEGPanelBufferedImage.getHeight(this));

setPreferredSize(d);

revalidate();

repaint();

}

/** Paints the component.

* @param g Graphics object used for the painting

*/

public void paintComponent(Graphics g) {

super.paintComponent(g);

Dimension d = getSize();

g.setColor(getBackground());

g.fillRect(0, 0, d.width, d.height);

if (mJPEGPanelBufferedImage != null) {

g.drawImage(mJPEGPanelBufferedImage, 0, 0, this);

}

}

}

protected JPEGPanel mJpegPanel;

protected BufferedImage mBufferedImage;

protected JComboBox mSourcesCombo;

protected JToolBar mToolBar;

/** Constructor

*/

public JTwacker() {

super("測(cè)試");

mJpegPanel = new JPEGPanel();

JScrollPane ps = new JScrollPane(mJpegPanel,

JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,

JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

getContentPane().add(ps, BorderLayout.CENTER);

WindowListener wndCloser = new WindowAdapter() {

public void windowClosing(WindowEvent e) {

System.exit(0);

}

};

addWindowListener(wndCloser);

mToolBar = new JToolBar("Twain");

mToolBar.setFloatable(false);

addButtons();

getContentPane().add(mToolBar, BorderLayout.NORTH);

setSize(800, 600);

/* Center the frame */

Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();

Rectangle frameDim = getBounds();

setLocation(

(screenDim.width - frameDim.width) / 2,

(screenDim.height - frameDim.height) / 2

);

setVisible(true);

}

protected void addButtons(){

JButton _ab = new JButton("掃描");

_ab.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

acquireImage();

}

});

mToolBar.add(_ab);

mToolBar.addSeparator();

if (edu.ctgu.twain.JTwain.getInstance().isTwainAvailble()) {

String[] twainSources = JTwain.getInstance().getAvailableSources();

if (twainSources != null) {

mSourcesCombo = new JComboBox(twainSources);

} else {

mSourcesCombo = new JComboBox();

mSourcesCombo.addItem("NONE AVAILABLE");

}

} else {

mSourcesCombo = new JComboBox();

mSourcesCombo.addItem("NONE AVAILABLE");

}

mToolBar.add(mSourcesCombo);

}

protected void acquireImage() {

if (JTwain.getInstance().isTwainAvailble()){

if (mSourcesCombo.getItemCount() 0 ){

String _source = (String)mSourcesCombo.getSelectedItem();

if (_source != null){

String _filename = JTwain.getInstance().acquire(_source);

System.out.println(_filename);

if (_filename != null _filename.length() 0) {

File fChoosen = new File(_filename);

// savetofile(fChoosen);

showImage(fChoosen);

} else {

System.out.println("哎呀,怎么出錯(cuò)了!");

}

} // end if

} // end if

} // end if

}

protected void showImage(final File file) {

if (file == null || !file.exists()) {

return;

}

setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

Thread runner = new Thread() {

public void run() {

try {

FileInputStream in = new FileInputStream(file);

JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in);

mBufferedImage = decoder.decodeAsBufferedImage();

in.close();

SwingUtilities.invokeLater( new Runnable() {

public void run() {

reset();

}

});

}

catch (Exception ex) {

ex.printStackTrace();

}

setCursor(Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR));

}

};

runner.start();

}

//把掃描得到的圖片保存為文件,然后上傳到服務(wù)器或保存到數(shù)據(jù)庫(kù)中

protected void savetofile(final File file) {

try {

File mfile=new File("c:\\dd.jpg");

if (mfile.exists()) {

mfile.delete();

}else {

file.renameTo(mfile);

}

} catch (Exception e) {

e.printStackTrace();

// TODO: handle exception

}

}

protected void reset() {

if (mBufferedImage != null) {

mJpegPanel.setBufferedImage(mBufferedImage);

}

}

public static void main(String argv[]) {

new JTwacker();

}

}

-------------------------

package edu.ctgu.twain;

/*

這是調(diào)用動(dòng)態(tài)鏈接庫(kù)的類

*/

public class JTwain {

private static final JTwain mInstance = new JTwain();

protected final String DLL_NAME = "jtwain";

private JTwain() {

initLib();

}

public static JTwain getInstance(){

return mInstance;

}

public native boolean isTwainAvailble();

public native String[] getAvailableSources();

public native String acquire();

public native String acquire(String sourceName);

private void initLib(){

try {

System.loadLibrary(DLL_NAME);

}catch(Exception e) {

e.printStackTrace();

}

finally {

// System.out.println("Loading : " + DLL_NAME + ".dll");

}

}

}

用java程序來(lái)獲取掃描儀里面的數(shù)據(jù)

下面是一個(gè)解決方案 , 用到 Morena 6.0 Framework 框架 里的 javaTwain功能 , 貌似搜了一下

好像要收費(fèi)的,不過(guò)你可以找找是否有破解版的,沒有的話,那就只有走偏門了 看是否能通過(guò)反編譯 ,看改源代碼了......

RE:

javatwain may be a powerful solution,you can go to to download the newest package.

JavaTwain version 5.1 is a part of the Morena 6.0 Framework now.

below is an simple example:

/*

* $Id: ExampleShow.java,v 1.5 2002/07/15 13:48:55 mmotovsk Exp $

*

* Copyright (c) 1999-2002 Gnome spol. s r.o. All Rights Reserved.

*

* This software is the confidential and proprietary information of

* Gnome spol. s r.o. You shall not disclose such Confidential

* Information and shall use it only in accordance with the terms

* of the license agreement you entered into with Gnome.

*/

// JavaTwain package version 5.1

/**

ExampleShow demonstrates how to scan an image using defaults

from the Twain source.

*/

import java.awt.*;

import java.awt.event.*;

import SK.gnome.twain.*;

public class ExampleShow extends Frame

{ Image image;

public void paint(Graphics g)

{ if (null!=image)

g.drawImage(image, 0, 0, this);

}

WindowListener windowAdapter=new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{ System.exit(0);

}

};

public ExampleShow()

{ try

{ addWindowListener(windowAdapter);

setTitle("ExampleShow Frame Application");

// Open TWAIN select source dialog box

// and initialize the source selected by the user.

TwainSource source=TwainManager.selectSource(null);

image=Toolkit.getDefaultToolkit().createImage(source);

// wait for the image to be completed

MediaTracker tracker=new MediaTracker(this);

tracker.addImage(image, 0);

// this is the moment the scanner user interface pops up

System.err.println("Start loading image ...");

try

{ tracker.waitForAll();

}

catch (InterruptedException e)

{ System.err.println("Image loading was interrupted!");

e.printStackTrace();

}

tracker.removeImage(image);

System.err.println("Image loaded ...");

setSize(image.getWidth(this), image.getHeight(this));

setVisible(true);

TwainManager.close();

}

catch (TwainException e)

{ e.printStackTrace();

}

}

public static void main(String[] args)

{ new ExampleShow();

}

}

JAVA中的掃描儀

Scanner是jdk1.5新增的一個(gè)類,使用該類可創(chuàng)建一個(gè)對(duì)象,Scanner scan=new Scanner(System.in);意思是聲明一個(gè)Scanner類的對(duì)象,并實(shí)例化,system.in即接收鍵盤輸入。

如何在Java中調(diào)用掃描儀的源代碼

下載一個(gè)jar包,放在lib目錄下面,然后再把這個(gè)jar加入到項(xiàng)目里面就可以了,右鍵add as libary,就可以引用源代碼了

java掃描儀接收單個(gè)字符

import?java.util.Scanner;

public?class?Tese1{

{

public?static?void?main?(?String[]?args?)

{

Scanner?in?=?new?Scanner?(System.in);

System.out.println?("請(qǐng)輸入你的姓名");

String?name?=?in.next?();

System.out.println?("姓名:"?+?name);

System.out.println?("請(qǐng)輸入你的年齡");

int?age?=?in.nextInt?();

System.out.println?("年齡:"?+?age);

System.out.println?("請(qǐng)輸入你的性別");

String?xb?=?in.next?();

System.out.println?("性別:"?+?xb);

in.close?();

}

}

網(wǎng)站標(biāo)題:java掃描儀接收代碼,java掃描器代碼
網(wǎng)站地址:http://sd-ha.com/article44/dsihoee.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)企業(yè)網(wǎng)站制作、App設(shè)計(jì)ChatGPT、微信小程序標(biāo)簽優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司