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.

enter image description here

enter image description here

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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -