Created
June 9, 2016 09:05
-
-
Save ksu3101/d91b887ad73fc4b2445cd97bd2085dff to your computer and use it in GitHub Desktop.
resize Bitmap image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get Aspaect ratio image resize point | |
* | |
* @param src 원본 비트맵 이미지 | |
* @param maxValue 원하는 값 | |
* @return 리사이징된 비트맵의 width, height가 설정된 Point객체 혹은 null | |
*/ | |
public static Point createScaledBitmapSize(Bitmap src, int maxValue) { | |
Point p = null; | |
if (src != null) { | |
if (maxValue > 0) { | |
int width = src.getWidth(); | |
int newWidth = width; | |
int height = src.getHeight(); | |
int newHeight = height; | |
float ratio = 0.0f; | |
if (width > height) { | |
if (maxValue < width) { | |
ratio = maxValue / (float) width; | |
newHeight = (int) (height * ratio); | |
newWidth = maxValue; | |
} | |
} | |
else { | |
if (maxValue < height) { | |
ratio = maxValue / (float) height; | |
newWidth = (int) (width * ratio); | |
newHeight = maxValue; | |
} | |
} | |
p = new Point(newWidth, newHeight); | |
} | |
} | |
return p; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment