高风险报告
parent
97ee49780d
commit
2c80144598
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,158 @@
|
|||||||
|
package com.rehome.zhdcoa.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.ImageFormat;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.YuvImage;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author yocn
|
||||||
|
* @Date 2019/8/5 4:11 PM
|
||||||
|
* @ClassName BitmapUtil
|
||||||
|
*/
|
||||||
|
public class BitmapUtil {
|
||||||
|
public static Bitmap rotateBitmap(Bitmap origin, float rotate) {
|
||||||
|
if (origin == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int width = origin.getWidth();
|
||||||
|
int height = origin.getHeight();
|
||||||
|
Matrix matrix = new Matrix();
|
||||||
|
matrix.setRotate(rotate);
|
||||||
|
// 围绕原地进行旋转
|
||||||
|
Bitmap newBM = Bitmap.createBitmap(origin, 0, 0, width, height, matrix, false);
|
||||||
|
if (newBM.equals(origin)) {
|
||||||
|
return newBM;
|
||||||
|
}
|
||||||
|
origin.recycle();
|
||||||
|
return newBM;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] rotateYUV420Degree90(byte[] data, int imageWidth, int imageHeight) {
|
||||||
|
byte[] yuv = new byte[imageWidth * imageHeight * 3 / 2];
|
||||||
|
// Rotate the Y luma
|
||||||
|
int i = 0;
|
||||||
|
for (int x = 0; x < imageWidth; x++) {
|
||||||
|
for (int y = imageHeight - 1; y >= 0; y--) {
|
||||||
|
yuv[i] = data[y * imageWidth + x];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Rotate the U and V color components
|
||||||
|
i = imageWidth * imageHeight * 3 / 2 - 1;
|
||||||
|
for (int x = imageWidth - 1; x > 0; x = x - 2) {
|
||||||
|
for (int y = 0; y < imageHeight / 2; y++) {
|
||||||
|
yuv[i] = data[(imageWidth * imageHeight) + (y * imageWidth) + x];
|
||||||
|
i--;
|
||||||
|
yuv[i] = data[(imageWidth * imageHeight) + (y * imageWidth) + (x - 1)];
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return yuv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap getBitmapImageFromYUV(byte[] data, int width, int height) {
|
||||||
|
YuvImage yuvimage = new YuvImage(data, ImageFormat.NV21, width, height, null);
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 80, baos);
|
||||||
|
byte[] jdata = baos.toByteArray();
|
||||||
|
BitmapFactory.Options bitmapFatoryOptions = new BitmapFactory.Options();
|
||||||
|
bitmapFatoryOptions.inPreferredConfig = Bitmap.Config.RGB_565;
|
||||||
|
Bitmap bmp = BitmapFactory.decodeByteArray(jdata, 0, jdata.length, bitmapFatoryOptions);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] convertColorToByte(int color[]) {
|
||||||
|
if (color == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] data = new byte[color.length * 3];
|
||||||
|
for (int i = 0; i < color.length; i++) {
|
||||||
|
data[i * 3] = (byte) (color[i] >> 16 & 0xff);
|
||||||
|
data[i * 3 + 1] = (byte) (color[i] >> 8 & 0xff);
|
||||||
|
data[i * 3 + 2] = (byte) (color[i] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dumpFile(String fileName, byte[] data) {
|
||||||
|
FileOutputStream outStream;
|
||||||
|
try {
|
||||||
|
outStream = new FileOutputStream(fileName);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new RuntimeException("Unable to create output file " + fileName, ioe);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
outStream.write(data);
|
||||||
|
outStream.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new RuntimeException("failed writing data to file " + fileName, ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I420转nv21
|
||||||
|
*/
|
||||||
|
public static byte[] I420Tonv21(byte[] data, int width, int height) {
|
||||||
|
byte[] ret = new byte[data.length];
|
||||||
|
int total = width * height;
|
||||||
|
|
||||||
|
ByteBuffer bufferY = ByteBuffer.wrap(ret, 0, total);
|
||||||
|
ByteBuffer bufferVU = ByteBuffer.wrap(ret, total, total / 2);
|
||||||
|
|
||||||
|
bufferY.put(data, 0, total);
|
||||||
|
for (int i = 0; i < total / 4; i += 1) {
|
||||||
|
bufferVU.put(data[i + total + total / 4]);
|
||||||
|
bufferVU.put(data[total + i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveBitmap(String path, Bitmap bitmap) {
|
||||||
|
//获取文件
|
||||||
|
File file = new File(path);
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
fos = new FileOutputStream(file);
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
|
||||||
|
fos.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (fos != null) {
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap getBitmapFromAssets(Context context, String path) {
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
AssetManager am = context.getResources().getAssets();
|
||||||
|
try {
|
||||||
|
//读取assert 的文图
|
||||||
|
InputStream is = am.open(path);
|
||||||
|
bitmap = BitmapFactory.decodeStream(is);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/activity_sqxgdlr3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".ui.activity.WorkRiskListHuiBaoActivity">
|
||||||
|
|
||||||
|
<include layout="@layout/layout_base"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center|left">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_xydj"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="right|center_vertical"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="汇报内容:" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="300px"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_ms"
|
||||||
|
style="@style/editTextTheme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="300px"
|
||||||
|
android:gravity="top|left"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="90dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:background="@drawable/radius"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/cb_crop"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:text="是否裁剪图片"
|
||||||
|
android:textColor="#53575e"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/cb_compress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="是否压缩图片"
|
||||||
|
android:textColor="#53575e"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/cb_editor"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="是否开启图片编辑"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:textColor="#53575e"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:overScrollMode="never" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
Loading…
Reference in New Issue