|
|
|
@ -167,6 +167,7 @@ public class Camera2RawFragment extends Fragment {
|
|
|
|
|
* but the orientation of the has changed, and thus the preview rotation must be updated.
|
|
|
|
|
*/
|
|
|
|
|
private OrientationEventListener mOrientationListener;
|
|
|
|
|
private static ArrayList<PngPhotoBean> list = new ArrayList<>();//用来存储已拍照的照片名称
|
|
|
|
|
|
|
|
|
|
public static native boolean makeHdr(long exposureTime1, String path1, long exposureTime2, String path2, String outputPath);
|
|
|
|
|
|
|
|
|
@ -594,105 +595,13 @@ public class Camera2RawFragment extends Fragment {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Button takepic = view.findViewById(R.id.takepic);
|
|
|
|
|
Button button = view.findViewById(R.id.tojpg);
|
|
|
|
|
EditText baoguang = view.findViewById(R.id.baoguang);
|
|
|
|
|
EditText iso = view.findViewById(R.id.iso);
|
|
|
|
|
// if (exposureTime > 0) {
|
|
|
|
|
// baoguang.setText(exposureTime + "");
|
|
|
|
|
// }
|
|
|
|
|
// if (sensitivity > 0) {
|
|
|
|
|
// iso.setText(sensitivity + "");
|
|
|
|
|
// }
|
|
|
|
|
takepic.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
isHandTakePic = true;
|
|
|
|
|
String s1 = baoguang.getText().toString();
|
|
|
|
|
String s2 = iso.getText().toString();
|
|
|
|
|
if (s1 != null && !s1.equals("")) {
|
|
|
|
|
pic1 = Double.parseDouble(s1);
|
|
|
|
|
}
|
|
|
|
|
if (s2 != null && !s2.equals("")) {
|
|
|
|
|
// sensitivity = Integer.parseInt(s2);
|
|
|
|
|
pic2 = Double.parseDouble(s2);
|
|
|
|
|
}
|
|
|
|
|
takePicture();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
// File directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
|
|
|
|
|
// List<String> strings = RawToJpgConverter.listFiles(directory);
|
|
|
|
|
// if (strings != null && strings.size() > 0) {
|
|
|
|
|
// for (String item : strings) {
|
|
|
|
|
// if (item.contains("create")) {
|
|
|
|
|
// File file1 = new File(directory, item);
|
|
|
|
|
// File file2 = new File(directory, "create_" + item + ".jpg");
|
|
|
|
|
// try {
|
|
|
|
|
// RawToJpgConverter.convertRawToJpg(file1.getPath(), file2.getPath());
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
|
|
|
|
|
String dcimpath = directory.getPath();
|
|
|
|
|
List<String> strings = RawToJpgConverter.listFiles(directory);
|
|
|
|
|
long t1;
|
|
|
|
|
long t2;
|
|
|
|
|
String p1;
|
|
|
|
|
String p2;
|
|
|
|
|
ArrayList<PngPhotoBean> list = new ArrayList();
|
|
|
|
|
if (strings != null && strings.size() > 0) {
|
|
|
|
|
for (String item : strings) {
|
|
|
|
|
if (item.contains("create")) {
|
|
|
|
|
String[] s = item.split("_");
|
|
|
|
|
File file1 = new File(directory, item);
|
|
|
|
|
PngPhotoBean bean = new PngPhotoBean();
|
|
|
|
|
bean.etime = Long.parseLong(s[1]);
|
|
|
|
|
bean.path = file1.getPath();
|
|
|
|
|
list.add(bean);
|
|
|
|
|
if (list.size() == 2) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (list.size() == 2) {
|
|
|
|
|
PngPhotoBean bean = list.get(0);
|
|
|
|
|
PngPhotoBean bean1 = list.get(1);
|
|
|
|
|
makeHdr(bean.etime, bean.path, bean1.etime, bean1.path, dcimpath + "/" + "hdr_" + generateTimestamp() + ".png");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// mTextureView.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
|
// int actionMasked = MotionEventCompat.getActionMasked(event);
|
|
|
|
|
// int fingerX, fingerY;
|
|
|
|
|
// int length = (int) (getResources().getDisplayMetrics().density * 80);
|
|
|
|
|
// switch (actionMasked) {
|
|
|
|
|
// case MotionEvent.ACTION_DOWN:
|
|
|
|
|
// fingerX = (int) event.getX();
|
|
|
|
|
// fingerY = (int) event.getY();
|
|
|
|
|
//
|
|
|
|
|
// mIvFocus.setX(fingerX - length / 2);
|
|
|
|
|
// mIvFocus.setY(fingerY - length / 2);
|
|
|
|
|
//
|
|
|
|
|
// mIvFocus.setVisibility(View.VISIBLE);
|
|
|
|
|
// triggerFocusArea(fingerX, fingerY);
|
|
|
|
|
//
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1167,8 +1076,8 @@ public class Camera2RawFragment extends Fragment {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the best preview size for these view dimensions and configured JPEG size.
|
|
|
|
|
// Size previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedViewWidth, rotatedViewHeight, maxPreviewWidth, maxPreviewHeight, largestJpeg);
|
|
|
|
|
Size previewSize = new Size(3840, 2160);
|
|
|
|
|
Size previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedViewWidth, rotatedViewHeight, maxPreviewWidth, maxPreviewHeight, largestJpeg);
|
|
|
|
|
// Size previewSize = new Size(3840, 2160);
|
|
|
|
|
|
|
|
|
|
if (swappedDimensions) {
|
|
|
|
|
mTextureView.setAspectRatio(previewSize.getHeight(), previewSize.getWidth());
|
|
|
|
@ -1459,13 +1368,6 @@ public class Camera2RawFragment extends Fragment {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runnable that saves an {@link Image} into the specified {@link File}, and updates
|
|
|
|
|
* {@link android.provider.MediaStore} to include the resulting file.
|
|
|
|
|
* <p/>
|
|
|
|
|
* This can be constructed through an {@link ImageSaverBuilder} as the necessary image and
|
|
|
|
|
* result information becomes available.
|
|
|
|
|
*/
|
|
|
|
|
private static class ImageSaver implements Runnable {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1550,34 +1452,26 @@ public class Camera2RawFragment extends Fragment {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Decrement reference count to allow ImageReader to be closed to free up resources.
|
|
|
|
|
mReader.close();
|
|
|
|
|
|
|
|
|
|
// If saving the file succeeded, update MediaStore.
|
|
|
|
|
if (success) {
|
|
|
|
|
File directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
|
|
|
|
|
String directoryPath = directory.getPath();
|
|
|
|
|
File file = new File(directory, "create_" + mExpostime + "_" + generateTimestamp() + ".png");
|
|
|
|
|
String path = file.getPath();
|
|
|
|
|
try {
|
|
|
|
|
RawToJpgConverter.convertRawToJpg(mFile.getPath(), file.getPath());
|
|
|
|
|
RawToJpgConverter.convertRawToJpg(mFile.getPath(), path);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// covertNum++;
|
|
|
|
|
// MediaScannerConnection.scanFile(mContext, new String[]{mFile.getPath()},
|
|
|
|
|
// /*mimeTypes*/null, new MediaScannerConnection.MediaScannerConnectionClient() {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onMediaScannerConnected() {
|
|
|
|
|
// // Do nothing
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onScanCompleted(String path, Uri uri) {
|
|
|
|
|
// Log.i(TAG, "Scanned " + path + ":");
|
|
|
|
|
// Log.i(TAG, "-> uri=" + uri);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
PngPhotoBean bean = new PngPhotoBean();
|
|
|
|
|
bean.setEtime(mExpostime);
|
|
|
|
|
bean.setPath(path);
|
|
|
|
|
list.add(bean);
|
|
|
|
|
if (list.size() == 2) {
|
|
|
|
|
PngPhotoBean bean1 = list.get(0);
|
|
|
|
|
PngPhotoBean bean2 = list.get(1);
|
|
|
|
|
makeHdr(bean1.getEtime(), bean1.getPath(), bean2.getEtime(), bean2.getPath(), directoryPath + "/" + "hdr_" + generateTimestamp() + ".png");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|