java - BitmapFactory Not working in Android -


this line of code returns null after cropping:

this.bmp = bitmapfactory.decodefile(this.imagefileuri.getpath()); 

this crop method:

 private void performcrop() {       this.imagefileuri = uri.fromfile(this.file);       intent var1 = new intent("com.android.camera.action.crop");       var1.setdataandtype(this.imagefileuri, "image/*");       system.out.println(this.imagefileuri.getpath());       var1.putextra("crop", "true");       var1.putextra("scale", true);       var1.putextra("return-data", true);      // var1.putextra("output", this.imagefileuri);       intent.putextra(mediastore.extra_output, this.imagefileuri);       this.startactivityforresult(var1, 1);    } 

i have tried using custom method return bitmap still returns null. method

public static bitmap decodefile(string path) {        int orientation;        try {            if (path == null) {                return null;            }            // decode image size            bitmapfactory.options o = new bitmapfactory.options();            o.injustdecodebounds = true;            // find correct scale value. should power of 2.            final int required_size = 70;            int width_tmp = o.outwidth, height_tmp = o.outheight;            int scale = 1;             bitmapfactory.options o2 = new bitmapfactory.options();            o2.insamplesize = scale;            bitmap bm = bitmapfactory.decodefile(path, o2);            bitmap bitmap = bm;             exifinterface exif = new exifinterface(path);             orientation = exif                    .getattributeint(exifinterface.tag_orientation, 1);             log.e("exifinteface .........", "rotation =" + orientation);             // exif.setattribute(exifinterface.orientation_rotate_90, 90);             log.e("orientation", "" + orientation);            matrix m = new matrix();             if ((orientation == exifinterface.orientation_rotate_180)) {                m.postrotate(180);                // m.postscale((float) bm.getwidth(), (float) bm.getheight());                // if(m.prerotate(90)){                log.e("in orientation", "" + orientation);                bitmap = bitmap.createbitmap(bm, 0, 0, bm.getwidth(),                        bm.getheight(), m, true);                return bitmap;            } else if (orientation == exifinterface.orientation_rotate_90) {                m.postrotate(90);                log.e("in orientation", "" + orientation);                bitmap = bitmap.createbitmap(bm, 0, 0, bm.getwidth(),                        bm.getheight(), m, true);                return bitmap;            } else if (orientation == exifinterface.orientation_rotate_270) {                m.postrotate(270);                log.e("in orientation", "" + orientation);                bitmap = bitmap.createbitmap(bm, 0, 0, bm.getwidth(),                        bm.getheight(), m, true);                return bitmap;            }            return bitmap;        } catch (exception e) {            return null;        }     } 

and calling above method way:

this.bmp = myclass.decodefile(this.imagefileuri.getpath()); 

kindly assist!


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -