I have written an android OpenCV application and for testing my functions, I need to load some sample images from my computer and save the results back to my computer to see how if the functions work correctly. I put a jpg file under resources folder in Android Studio and I could load a file from this folder but BitmapFactory always returns null. how should I solve this issue?
File file = getFileFromPath(this, "roi_RGB.jpg");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.inSampleSize = 4;
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
I load the images as :
private static File getFileFromPath(Object obj, String fileName) {
ClassLoader classLoader = obj.getClass().getClassLoader();
URL resource = classLoader.getResource(fileName);
return new File(resource.getPath());
}
bitmap is always null.