The browser uses Webcam+flash to enable the camera and complete the photo

Source: Internet
Author: User
Tags base64

We all like to talk about the college entrance examination, but I do not want to mention, because the author of the college Entrance examination is not ideal, so depressed. Later, it was a crush on the game until last month, it can be said that it has been ignorant for a long time. The hot temper is followed, although the time is no longer, temper still exists. What to do, the author uses hbuilder write something to eliminate the fire. I'm glad to have a little chatter. The following code is directly on:

<! DOCTYPE html>


Next, we click Launch Camera.

When you choose to take a photo, the photo data is sent to the background in a binary encoded format for storage.

//1、处理Base64图片代码 String imgaePath = "c:\\"+DateUtil.getTimestamp()+"20180820.jpg"; GenerateImage(imagedata, imgaePath);
```//对字节数组字符串进行Base64解码,并生成图片 20180820private void GenerateImage(String imagedata, String imgaePath) { if(imagedata.isEmpty()){//判断图像数据是否为空 return; } BASE64Decoder decoder = new BASE64Decoder(); try {//进行Base64解码 byte[] bytes = decoder.decodeBuffer(imagedata); for (int i = 0; i < bytes.length; i++) { if(bytes[i] < 0){//调整异常数据 bytes[i] += 256; } } //生成jpeg图片 OutputStream out = new FileOutputStream(imgaePath); out.write(bytes); out.flush(); out.close(); return; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }}
接下来,你会在你的电脑C盘下,找到这张照片。

好了,笔者要去吃鸡了。

The browser uses Webcam+flash to enable the camera and complete the photo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.