I cannot understand how the android scaling works, I have used a matrix and postScaled a bitmap from the size 540 by 960 and it turns out 682 by 368 when I scale by 1.067 and 1.023.
540 * 1.067 = 576 not 368
960 * 1.023 = 981 not 682
I cannot understand the logics of scaling, also the value it scales by changes from 0.67 to 0.7 instead of the 1.067 and 1.023 that I put in there.
Does anyone know how this works and help me?
EDIT: Heres the code that does the scaling:
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;
}
I dont know about Bitmap.createScaledBitmap but if it helps it gives the same result, so I guess its just a scaled matrix as here :/
EDIT2: I found out that scaling by 1.5f on both axes made the bitmap the original size, now the scaling factor gotten by dividing lengths doesn't seem to match up with the scaling Matrixes use so I have no idea how to "convert" them for it to work properly.
I found out that the Matrix scaling divides the value put in by 1.5f therefore it didnt make any sense when it scaled so weird. Heres what I have added into the function now that works fine(at least for scaling 1f and above):
if(Vars.screenWidthMulti > 1 && Vars.screenWidthMulti != 1){
scaleWidth = 1.5f+(Vars.screenWidthMulti-1)*1.5f;
scaleHeight = 1.5f+(Vars.screenHeightMulti-1)*1.5f;
}else if(Vars.screenWidthMulti == 1){
scaleWidth = 1f;
scaleHeight = 1f;
}else if(Vars.screenWidthMulti < 1){
scaleWidth = 1.5f -(Vars.screenWidthMulti*1.5f);
scaleHeight = 1.5f -(Vars.screenHeightMulti*1.5f);
}
note: I havent tested the scaling below 1 yet so bevare.