jiangdongguo
7 years ago
35 changed files with 270 additions and 360 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,13 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="animated-vector-drawable-25.3.1"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://$USER_HOME$/.android/build-cache/17dbf24c311d327da7565d7b9b8c7205d2b3f2c6/output/jars/classes.jar!/" /> |
|
||||
<root url="file://$USER_HOME$/.android/build-cache/17dbf24c311d327da7565d7b9b8c7205d2b3f2c6/output/res" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/animated-vector-drawable/25.3.1/animated-vector-drawable-25.3.1-sources.jar!/" /> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/animated-vector-drawable/25.3.1/animated-vector-drawable-25.3.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
@ -1,11 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="butterknife-annotations-8.8.1"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-annotations/8.8.1/bc373fb6bc7bca3035041b924f158fd2b946ee8d/butterknife-annotations-8.8.1.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-annotations/8.8.1/4f68b7085132dfeb48a0473bc589fdee8a3de757/butterknife-annotations-8.8.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
@ -1,11 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="butterknife-compiler-8.8.1"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/8.8.1/b2f4505a1babb7b7c11abbbf8ea4c90b18c3aeac/butterknife-compiler-8.8.1.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.jakewharton/butterknife-compiler/8.8.1/97cf58a258bb347d7b8642f3f4996abd0f6adb6/butterknife-compiler-8.8.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
@ -1,13 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="espresso-idling-resource-2.2.2"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://$USER_HOME$/.android/build-cache/5c86e8eab3d72b00394bf9e598645f884c7c63a5/output/jars/classes.jar!/" /> |
|
||||
<root url="file://$USER_HOME$/.android/build-cache/5c86e8eab3d72b00394bf9e598645f884c7c63a5/output/res" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/test/espresso/espresso-idling-resource/2.2.2/espresso-idling-resource-2.2.2-sources.jar!/" /> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/test/espresso/espresso-idling-resource/2.2.2/espresso-idling-resource-2.2.2-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
@ -1,13 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="exposed-instrumentation-api-publish-0.5"> |
|
||||
<CLASSES> |
|
||||
<root url="file://$USER_HOME$/.android/build-cache/a6ea49c91460d946e46649e01e209781e6cf4b4a/output/res" /> |
|
||||
<root url="jar://$USER_HOME$/.android/build-cache/a6ea49c91460d946e46649e01e209781e6cf4b4a/output/jars/classes.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/test/exposed-instrumentation-api-publish/0.5/exposed-instrumentation-api-publish-0.5-sources.jar!/" /> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/test/exposed-instrumentation-api-publish/0.5/exposed-instrumentation-api-publish-0.5-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
@ -1,11 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="support-annotations-25.3.1"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/support-annotations/25.3.1/support-annotations-25.3.1.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/support-annotations/25.3.1/support-annotations-25.3.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
@ -1,17 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="support-media-compat-25.3.1"> |
|
||||
<ANNOTATIONS> |
|
||||
<root url="jar://$USER_HOME$/.android/build-cache/f1ca6919d3e9176e08e199c56de54351aac5f05a/output/annotations.zip!/" /> |
|
||||
<root url="jar://$USER_HOME$/.android/build-cache/f1ca6919d3e9176e08e199c56de54351aac5f05a/output/annotations.zip!/" /> |
|
||||
</ANNOTATIONS> |
|
||||
<CLASSES> |
|
||||
<root url="file://$USER_HOME$/.android/build-cache/f1ca6919d3e9176e08e199c56de54351aac5f05a/output/res" /> |
|
||||
<root url="jar://$USER_HOME$/.android/build-cache/f1ca6919d3e9176e08e199c56de54351aac5f05a/output/jars/classes.jar!/" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/support-media-compat/25.3.1/support-media-compat-25.3.1-sources.jar!/" /> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/support-media-compat/25.3.1/support-media-compat-25.3.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
@ -1,13 +0,0 @@ |
|||||
<component name="libraryTable"> |
|
||||
<library name="support-vector-drawable-25.3.1"> |
|
||||
<CLASSES> |
|
||||
<root url="jar://$USER_HOME$/.android/build-cache/7a405513524c444d4aa139ab61911f927325318f/output/jars/classes.jar!/" /> |
|
||||
<root url="file://$USER_HOME$/.android/build-cache/7a405513524c444d4aa139ab61911f927325318f/output/res" /> |
|
||||
</CLASSES> |
|
||||
<JAVADOC /> |
|
||||
<SOURCES> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/support-vector-drawable/25.3.1/support-vector-drawable-25.3.1-sources.jar!/" /> |
|
||||
<root url="jar://E:/Environment/android-sdk-windows/extras/android/m2repository/com/android/support/support-vector-drawable/25.3.1/support-vector-drawable-25.3.1-sources.jar!/" /> |
|
||||
</SOURCES> |
|
||||
</library> |
|
||||
</component> |
|
Binary file not shown.
After Width: | Height: | Size: 5.2 MiB |
@ -1,82 +0,0 @@ |
|||||
package com.jiangdg.usbcamera.task; |
|
||||
|
|
||||
import android.content.Context; |
|
||||
import android.graphics.Bitmap; |
|
||||
import android.graphics.BitmapFactory; |
|
||||
import android.graphics.ImageFormat; |
|
||||
import android.graphics.Rect; |
|
||||
import android.graphics.YuvImage; |
|
||||
import android.os.AsyncTask; |
|
||||
|
|
||||
import com.jiangdg.usbcamera.utils.YUVBean; |
|
||||
|
|
||||
import java.io.ByteArrayOutputStream; |
|
||||
import java.io.File; |
|
||||
import java.io.FileNotFoundException; |
|
||||
import java.io.FileOutputStream; |
|
||||
import java.io.IOException; |
|
||||
|
|
||||
/**保存YUV格式(NV21)图片 |
|
||||
* |
|
||||
* Created by jiangdongguo on 2017-12-25下午9:13:01 |
|
||||
*/ |
|
||||
public class SaveYuvImageTask extends AsyncTask<Void, Void, Void> { |
|
||||
private static final String TAG = "SaveYuvImageTask"; |
|
||||
private YUVBean yuvBean; |
|
||||
private Context mContext; |
|
||||
//转换结果回调接口
|
|
||||
private OnSaveYuvResultListener mListener; |
|
||||
|
|
||||
public interface OnSaveYuvResultListener{ |
|
||||
void onSaveResult(String savePath); |
|
||||
} |
|
||||
|
|
||||
public SaveYuvImageTask(YUVBean yuvBean, OnSaveYuvResultListener mListener) { |
|
||||
this.yuvBean = yuvBean; |
|
||||
this.mListener = mListener; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected Void doInBackground(Void... params) { |
|
||||
if (yuvBean == null || yuvBean.getWidth() == 0 |
|
||||
|| yuvBean.getHeight() == 0 || yuvBean.getYuvData() == null) { |
|
||||
return null; |
|
||||
} |
|
||||
saveYuv2Jpeg(yuvBean.getYuvData(),yuvBean.getWidth(),yuvBean.getHeight()); |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
private void saveYuv2Jpeg(byte[] data,int width,int height){ |
|
||||
YuvImage yuvImage = new YuvImage(data, ImageFormat.NV21, width, height, null); |
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); |
|
||||
boolean result = yuvImage.compressToJpeg(new Rect(0, 0, width, height), 100, bos); |
|
||||
if(result){ |
|
||||
byte[] buffer = bos.toByteArray(); |
|
||||
Bitmap bmp = BitmapFactory.decodeByteArray(buffer, 0, buffer.length); |
|
||||
bmp.recycle(); |
|
||||
String savPath = yuvBean.getPicPath(); |
|
||||
File file = new File(savPath); |
|
||||
FileOutputStream fos = null; |
|
||||
try { |
|
||||
fos = new FileOutputStream(file); |
|
||||
} catch (FileNotFoundException e) { |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos); |
|
||||
try { |
|
||||
fos.flush(); |
|
||||
fos.close(); |
|
||||
//传递转换结果给调用者
|
|
||||
mListener.onSaveResult(savPath); |
|
||||
} catch (IOException e) { |
|
||||
e.printStackTrace(); |
|
||||
mListener.onSaveResult(null); |
|
||||
} |
|
||||
} |
|
||||
try { |
|
||||
bos.close(); |
|
||||
} catch (IOException e) { |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
@ -1,45 +0,0 @@ |
|||||
package com.jiangdg.usbcamera.utils; |
|
||||
|
|
||||
/** NV21数据类 |
|
||||
* |
|
||||
* Created by jiangdongguo on 2018/1/26. |
|
||||
*/ |
|
||||
|
|
||||
public class YUVBean { |
|
||||
private int width; |
|
||||
private int height; |
|
||||
private byte[] yuvData; |
|
||||
private String picPath; |
|
||||
|
|
||||
public int getWidth() { |
|
||||
return width; |
|
||||
} |
|
||||
|
|
||||
public void setWidth(int width) { |
|
||||
this.width = width; |
|
||||
} |
|
||||
|
|
||||
public int getHeight() { |
|
||||
return height; |
|
||||
} |
|
||||
|
|
||||
public void setHeight(int height) { |
|
||||
this.height = height; |
|
||||
} |
|
||||
|
|
||||
public byte[] getYuvData() { |
|
||||
return yuvData; |
|
||||
} |
|
||||
|
|
||||
public void setYuvData(byte[] yuvData) { |
|
||||
this.yuvData = yuvData; |
|
||||
} |
|
||||
|
|
||||
public String getPicPath() { |
|
||||
return picPath; |
|
||||
} |
|
||||
|
|
||||
public void setPicPath(String picPath) { |
|
||||
this.picPath = picPath; |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue