Image Editing
This documentation outlines the guidelines for utilizing the Image Module SDK, which offers powerful image editing tools. The SDK provides straightforward methods to incorporate advanced image editing functionalities into your
Prerequisites
Ensure you have integrated the TruVideo Core SDK into your project and completed with the authentication process
Camera module will provide MediaItem or simply provide filepath to upload (optional)
Edit an Image
To edit an image, follow these steps:
Step 1 : Intialize ActivityResultLauncher
import androidx.activity.result.ActivityResultLauncher;
import androidx.appcompat.app.AppCompatActivity;
import com.truvideo.sdk.image.ui.edit.activities.edit.TruvideoSdkImageEditContract;
import com.truvideo.sdk.image.ui.edit.activities.edit.TruvideoSdkImageEditParams;
public class YourActivity extends AppCompatActivity{
ActivityResultLauncher<TruvideoSdkImageEditParams> launcher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// initiate imageLauncher
launcher = registerForActivityResult(
new TruvideoSdkImageEditContract()
, result -> {
// handle result
});
//...rest of your code
}
}
Step 2 : Call Image Edit
//path: actual iamge path
public static void editImage(Context context, String path){
// get output path for storing new image
String outputPath = context.getFilesDir().getPath()+System.currentTimeMillis()+".png";
launcher.launch(new TruvideoSdkImageEditParams(path,outputPath));
}
Finalize :
After completing this steps the function should look like
import androidx.activity.result.ActivityResultLauncher;
import androidx.appcompat.app.AppCompatActivity;
import com.truvideo.sdk.image.ui.edit.activities.edit.TruvideoSdkImageEditContract;
import com.truvideo.sdk.image.ui.edit.activities.edit.TruvideoSdkImageEditParams;
public class YourActivity extends AppCompatActivity{
ActivityResultLauncher<TruvideoSdkImageEditParams> launcher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// initiate imageLauncher
launcher = registerForActivityResult(
new TruvideoSdkImageEditContract()
, result -> {
// handle result
});
//...rest of your code
}
//path: actual iamge path
void editImage(){
// get output path for storing new image
String outputPath = getFilesDir().getPath()+System.currentTimeMillis()+".png";
launcher.launch(new TruvideoSdkImageEditParams(
path, // input path of image
outputPath
));
}
}
Final Result -

Last updated
Was this helpful?