bitmap - Android postScale not scaling as expected -


i have got load of bitmaps trying scale depending on screen size, way dividing current device screen size test phones size because images made according screensize.

the function use below

public bitmap resizebitmap(bitmap b){       int width = b.getwidth();       int height = b.getheight();       matrix max = new matrix();        max.postscale(vars.screenwidthmulti, vars.screenheightmulti);       bitmap resizedbitmap = bitmap.createbitmap(b, 0, 0, width, height, max, false);       return resizedbitmap; } 

screenwidthmulti , screenheightmulti gotten dividing current screensize float value same test devices screen. part works fine. if use device screensize of 1024/552 , device 960/540 scaling values 1.06666667 width , 1.02222223 height fine.

now problem when postscale values doesnt scale them i'd expect. example background image same size test device put in size of bitmap outputted 683 368 doesn't make sense me ever! have tried prescale , setscale doesnt change better either.

is there other way might easier , works or me not understanding this?

edit: tried putting in value of 2f in setscale , turned out quite strange, 540*2 turned out 720 cannot head around.

you created matrix, don't need post or prescale, use setscale:

matrix max = new matrix(); max.setscale(vars.screenwidthmulti, vars.screenheightmulti); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -