android - Resize the bitmap -
im project capturing image camera app , displaying image in listview using following code . mysimplecursoradapter:
public class mysimplecursoradapter extends simplecursoradapter { public mysimplecursoradapter(context context, int layout, cursor c, string[] from, int[] to) { super(context, layout, c, from, to); } @override public void setviewimage(imageview image_v, string id) { string path = id; bitmap b = bitmapfactory.decodefile(path); image_v.setimagebitmap(resizedbitmap); } }
list.java
string[] = new string[]{dbmanager.babyname, dbmanager.baby_image}; int[] = new int[] {/*r.id.list_id,*/ r.id.drname12,r.id.imageview1};//,r.id.list_date};{ mysimplecursoradapter adapter = new mysimplecursoradapter(this, r.layout.rowlayout, c1, from, to); list.setadapter(adapter);
every things working fine till point when try resize bitmap using piece of code
bitmap resizedbitmap = bitmap.createscaledbitmap(b, 200, 200, true);
its giving following error :
05-22 07:13:07.562: e/androidruntime(478): fatal exception: main 05-22 07:13:07.562: e/androidruntime(478): java.lang.nullpointerexception 05-22 07:13:07.562: e/androidruntime(478): @ android.graphics.bitmap.createscaledbitmap(bitmap.java:380) 05-22 07:13:07.562: e/androidruntime(478): @ com.example.tottal.baby.care.mysimplecursoradapter.setviewimage(mysimplecursoradapter.java:22) 05-22 07:13:07.562: e/androidruntime(478): @ android.support.v4.widget.simplecursoradapter.bindview(simplecursoradapter.java:143) 05-22 07:13:07.562: e/androidruntime(478): @ android.support.v4.widget.cursoradapter.getview(cursoradapter.java:256)
error here check properly
bitmap b = bitmapfactory.decodefile(path);
your variable path
or b
may null.
check these variable not equal null use them.
Comments
Post a Comment