bitmap - Watermark coming on whole image Android -
i want place watermark on bottom right of picture. but, in mobiles coming , in mobile phones, watermark coming on whole image.
here code:
rotatedbitmap = bitmap.createbitmap(loadedimage, 0, 0, loadedimage.getwidth(), loadedimage.getheight(), rotatematrix, false); int w = rotatedbitmap.getwidth(); int h = rotatedbitmap.getheight(); bitmap result = bitmap.createbitmap(w, h, rotatedbitmap.getconfig()); canvas canvas = new canvas(result); canvas.drawbitmap(rotatedbitmap, 0, 0, null); bitmap watermark = bitmapfactory.decoderesource(getresources(), r.drawable.watermark2); int ww = watermark.getwidth(); int hh = watermark.getheight(); canvas.drawbitmap(watermark,(w-ww),(h-hh), null);
edit: here screenshots of result. in second picture, watermark coming , in first picture, coming on whole picture.
make use of aspect ratio. calculate aspect ratio of device , accordingly calculate appropriate size water mark.
how calculate aspect ratio?
check width , height of screen whichever bigger divide smaller 1 example:
if(screen_width > screen_height){ aspectratio = screen_width/screen_height }else{ aspectratio = screen_height/screen_width }
now have calculated aspect ratio multiply size of water mark , scale accordingly.
like:
float ww = watermark.getwidth()*aspectratio; float wh = watermark.getheight()*aspectratio;
and use these values.
hope helps...
Comments
Post a Comment