how to modify this code to stretch the image to full screen in android -
i got code draws images according size of image. want stretch image full screen. tried lot nothing helped. can me? in advance
public bitmap getbitmap(int width, int height, int index) { bitmap b = bitmap.createbitmap(width, height, bitmap.config.argb_8888); b.erasecolor(0xf000ffff); canvas c = new canvas(b); drawable d = getresources().getdrawable(mbitmapids[index]); int margin = 1; int border =1 ; rect r = new rect(margin, margin, width - margin, height - margin); int imagewidth = r.width() - (border * 2); int imageheight = imagewidth * d.getintrinsicheight() / d.getintrinsicwidth(); if (imageheight > r.height() - (border * 2)) { imageheight = r.height() - (border * 2); imagewidth = imageheight * d.getintrinsicwidth() / d.getintrinsicheight(); } r.left += ((r.width() - imagewidth) / 2) - border; r.right = r.left + imagewidth + border + border; r.top += ((r.height() - imageheight) / 2) - border; r.bottom = r.top + imageheight + border + border; paint p = new paint(); p.setcolor(0xffc0c0c0); c.drawrect(r, p); r.left += border; r.right -= border; r.top += border; r.bottom -= border; d.setbounds(r); d.draw(c); return b; }
check out this.................onclick method of thumbnail, can start new activity in fullscreen mode:
getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen);
and pass image uri or indicate image source new activity :
intent intent = new intent(youactivity.this, fullimage.class); intent.putextra("imageuri", r.drawable.yourimage); // or path image.
in fullimage activity class
imageview icon = (imageview) findviewbyid(r.id.myimage); bitmapfactory.options options = new bitmapfactory.options(); options.intempstorage = new byte[3*1024]; bitmap ops = bitmapfactory.decodefile(path, options); // instead path can image previous activity. icon.setimagebitmap(ops);
Comments
Post a Comment