Hi, So i have a background image that I want to scale.
My bitmap image is 640 X 240. And I would like to scale by a factor of 2 to get a result of of 1280 X 480. Where in the code below should I do a multiplication of 2 such that I'm able to scale the image by a factor of 2? I can't understand the code below well enough to know where I should add my scaling factor. Hope someone with more windows GDI programming experience is able to help. If the scaling is not done here, then can I have a rough idea of how to scale? New to windows GDI. Thank you.
Note: The reason I don't post my whole code is because the file is too big.
Mmm lets take this example, how do I scale it up instead of down? I know its not c++ but I just need the concept of scaling up. Hope you or anyone is able to help.
1 2 3 4 5 6 7 8 9 10 11 12
publicstatic Bitmap scaleDown(Bitmap realImage, float maxImageSize,
boolean filter) {
float ratio = Math.min(
(float) maxImageSize / realImage.getWidth(),
(float) maxImageSize / realImage.getHeight());
int width = Math.round((float) ratio * realImage.getWidth());
int height = Math.round((float) ratio * realImage.getHeight());
Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
height, filter);
return newBitmap;
}