Comments (2)
File outputFile = FileUtils.genEditFile();
try {
Intent intent = new ImageEditorIntentBuilder(this, root, outputFile.getAbsolutePath())
.withAddText() // Add the features you need
.withPaintFeature()
.withFilterFeature()
.withRotateFeature()
.withCropFeature()
.withBrightnessFeature()
.withSaturationFeature()
.withBeautyFeature()
.withStickerFeature()
.forcePortrait(true) // Add this to force portrait mode (It's set to false by default)
.setSupportActionBarVisibility(false) // To hide app's default action bar
.build();
EditImageActivity.start(ImagePriview.this, intent, PHOTO_EDITOR_REQUEST_CODE);
} catch (Exception e) {
Log.e("Demo App", e.getMessage()); // This could throw if either sourcePath
or outputPath
is blank or Null
}
than cretate FileUtils Class:
public class FileUtils {
public static final String FOLDER_NAME = "Destination File Name";
/**
* 获取存贮文件的文件夹路径
*
* @return
*/
public static File createFolders() {
File baseDir;
if (android.os.Build.VERSION.SDK_INT < 8) {
baseDir = Environment.getExternalStorageDirectory();
} else {
baseDir = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
}
if (baseDir == null)
return Environment.getExternalStorageDirectory();
File aviaryFolder = new File(baseDir, FOLDER_NAME);
if (aviaryFolder.exists())
return aviaryFolder;
if (aviaryFolder.isFile())
aviaryFolder.delete();
if (aviaryFolder.mkdirs())
return aviaryFolder;
return Environment.getExternalStorageDirectory();
}
public static File genEditFile(){
return FileUtils.getEmptyFile("FolderName"
+ System.currentTimeMillis() + ".jpg");
}
public static File getEmptyFile(String name) {
File folder = FileUtils.createFolders();
if (folder != null) {
if (folder.exists()) {
File file = new File(folder, name);
return file;
}
}
return null;
}
/**
* 删除指定文件
*
* @param path
* @return
*/
public static boolean deleteFileNoThrow(String path) {
File file;
try {
file = new File(path);
} catch (NullPointerException e) {
return false;
}
if (file.exists()) {
return file.delete();
}
return false;
}
/**
* 保存图片
*
* @param bitName
* @param mBitmap
*/
public static String saveBitmap(String bitName, Bitmap mBitmap) {
File baseFolder = createFolders();
File f = new File(baseFolder.getAbsolutePath(), bitName);
FileOutputStream fOut = null;
try {
f.createNewFile();
fOut = new FileOutputStream(f);
} catch (IOException e) {
e.printStackTrace();
}
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
try {
fOut.flush();
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
return f.getAbsolutePath();
}
// 获取文件夹大小
public static long getFolderSize(File file) throws Exception {
long size = 0;
try {
File[] fileList = file.listFiles();
for (int i = 0; i < fileList.length; i++) { // 如果下面还有文件
if (fileList[i].isDirectory()) {
size = size + getFolderSize(fileList[i]);
} else {
size = size + fileList[i].length();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return size;
}
/** * 格式化单位 * * @param size * @return */
public static String getFormatSize(double size) {
double kiloByte = size / 1024d;
int megaByte = (int) (kiloByte / 1024d);
return megaByte + "MB";
}
/**
*
* @Description:
* @Author 11120500
* @Date 2013-4-25
*/
public static boolean isConnect(Context context) {
try {
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
if (info.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
} catch (Exception e) {
}
return false;
}
}
from ananas.
Closing since it's similar to this issue which is resolved in version 1.2.5
.
from ananas.
Related Issues (20)
- Edit Image fetched from server HOT 1
- When I try to convert this project into kotlin and improt project into existing project using data binding HOT 1
- Change Text Size HOT 1
- ImageEditorIntentBuilder cant find symbol HOT 1
- Please add invert photo (flip) HOT 1
- App crash if big size image is provided HOT 4
- Text option not working HOT 2
- Error inflating class com.theartofdev.edmodo.cropper.CropImageView
- NullPointerException occur
- how to add only filter lib in project
- com.rahat.editorapp E/TAG: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter outputPath HOT 1
- Getting crash in Android 11(R) during selecting album HOT 2
- getting issue while add lib in kotlin project HOT 2
- upload image issue HOT 1
- Image not loading on First run of the app HOT 1
- Change Image Background Feature HOT 3
- Canvas: trying to draw too large(115200000bytes) bitmap. HOT 1
- Failed to resolve: com.github.iamutkarshtiwari:Ananas:1.2.6 HOT 1
- Image from Camera HOT 1
- Issue with withEditorTitle() HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ananas.