setPixel is not working in android -



setPixel is not working in android -

i using setpixel function manipulating bitmap not working. app crashes. 02-21 13:05:04.582: e/androidruntime(839): java.lang.illegalstateexception: not execute method of activity

public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.activity_main, menu); homecoming true; } public void function(view view){ bitmap img = bitmapfactory.decoderesource(getresources(), r.drawable.test); int imgwidth = img.getwidth(); int imgheight = img.getheight(); for(int x = 0; x < imgwidth; x++){ for(int y = 0; y < imgheight; y++){ int pixcolor = img.getpixel(x,y); if(pixcolor == color.white){ img.setpixel(x, y, color.black); } else if(pixcolor == color.black){ img.setpixel(x, y, color.white); } } } imageview imgview = (imageview) findviewbyid(r.id.imageview2); imgview.setimagebitmap(img); system.out.println("picture changed"); } }

android

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -