use of com.yydcdut.note.entity.SandPhoto in project PhotoNoter by yydcdut.
the class SandBoxServicePresenterImpl method makePhoto.
/**
* 做图
*
* @param sandPhoto
*/
private void makePhoto(SandPhoto sandPhoto) {
byte[] rowData = getDataFromFile(sandPhoto.getFileName(), sandPhoto.getSize());
if (rowData == null) {
return;
}
byte[] data;
if (sandPhoto.getImageFormat() == ImageFormat.JPEG) {
data = rowData;
} else {
data = decodeNV21(rowData, sandPhoto.getSandExif().getImageWidth(), sandPhoto.getSandExif().getImageLength());
}
if (data == null) {
return;
}
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
} catch (OutOfMemoryError e) {
YLog.e(e);
}
String fileName = sandPhoto.getTime() + ".jpg";
if (FilePathUtils.savePhoto(fileName, bitmap)) {
FilePathUtils.saveSmallPhoto(fileName, bitmap);
}
PhotoNote photoNote = new PhotoNote(fileName, sandPhoto.getTime(), sandPhoto.getTime(), "", "", sandPhoto.getTime(), sandPhoto.getTime(), sandPhoto.getCategoryId());
photoNote.setPaletteColor(Utils.getPaletteColor(bitmap));
mRxPhotoNote.savePhotoNote(photoNote).subscribe(photoNote1 -> {
}, (throwable -> YLog.e(throwable)));
try {
setExif(photoNote, sandPhoto.getSandExif(), sandPhoto.getCameraId(), sandPhoto.isMirror());
} catch (IOException e) {
YLog.e(e);
}
deleteFromDBAndSDCard(sandPhoto);
// bitmap.recycle();
System.gc();
}
use of com.yydcdut.note.entity.SandPhoto in project PhotoNoter by yydcdut.
the class SandBoxTest method testSave.
public void testSave() {
SandPhoto sandPhoto = new SandPhoto(SandPhoto.ID_NULL, 1l, "0", 1, false, 1, "111", 11, ImageFormat.JPEG, new SandExif(0, "s", "ss", 0, 0, 0, 1, "1", "1"));
mRxSandBox.saveOne(sandPhoto).subscribe(new Subscriber<SandPhoto>() {
@Override
public void onCompleted() {
YLog.i("yuyidong", "onCompleted");
}
@Override
public void onError(Throwable e) {
YLog.i("yuyidong", "onError");
}
@Override
public void onNext(SandPhoto sandPhoto) {
YLog.i("yuyidong", sandPhoto.toString());
}
});
}
use of com.yydcdut.note.entity.SandPhoto in project PhotoNoter by yydcdut.
the class CameraServicePresenterImpl method makePhoto.
/**
* 做图
*
* @param sandPhoto
*/
private void makePhoto(SandPhoto sandPhoto) {
byte[] rowData = getDataFromFile(sandPhoto.getFileName(), sandPhoto.getSize());
if (rowData == null) {
return;
}
byte[] data;
if (sandPhoto.getImageFormat() == ImageFormat.JPEG) {
data = rowData;
} else {
data = decodeNV21(rowData, sandPhoto.getSandExif().getImageWidth(), sandPhoto.getSandExif().getImageLength());
}
if (data == null) {
return;
}
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
String fileName = sandPhoto.getTime() + ".jpg";
if (FilePathUtils.savePhoto(fileName, bitmap)) {
FilePathUtils.saveSmallPhoto(fileName, bitmap);
}
PhotoNote photoNote = new PhotoNote(fileName, sandPhoto.getTime(), sandPhoto.getTime(), "", "", sandPhoto.getTime(), sandPhoto.getTime(), sandPhoto.getCategoryId());
photoNote.setPaletteColor(Utils.getPaletteColor(bitmap));
mRxPhotoNote.savePhotoNote(photoNote).subscribe(photoNote1 -> {
try {
setExif(photoNote, sandPhoto.getSandExif(), sandPhoto.getCameraId(), sandPhoto.isMirror());
} catch (IOException e) {
YLog.e(e);
}
deleteFromDBAndSDCard(sandPhoto);
mCameraServiceView.sendBroadCast();
}, (throwable -> YLog.e(throwable)));
//todo bitmap可以重复利用?
bitmap.recycle();
System.gc();
}
Aggregations