어떤 화면 크기에서도 작동해야하는 그래픽 응용 프로그램을 개발하려면 약간의 생각이 필요합니다. 일반적으로 화면에 맞게 고해상도 그래픽과 눈금을 만듭니다.android 비트 맵 - 모범 사례
내가 밀도 (DP) 작업을 시도하지만, 그 다음 다른 내 그래픽을 확장 할 수있는 더 좋은 방법을 찾을 수 없습니다 내가 를 사용하여 솔루션을 사용하여 더 복잡한 것 같다 "실제 픽셀" 의 사용을 피하는 추천을 본 적이나는 내 이미지의 크기를 조절하는 데이 클래스를 생성 장치 화면 (실제 픽셀)
를 사용하는이 (여전히 장치가 다른 종횡비가) 내 대부분의 문제를 해결하고 잘 작동하는 것 같다 (실제 픽셀 기준) .
public class BitmapHelper {
// Scale and keep aspect ratio
static public Bitmap scaleToFitWidth(Bitmap b, int width) {
float factor = width/(float) b.getWidth();
return Bitmap.createScaledBitmap(b, width, (int) (b.getHeight() * factor), false);
}
// Scale and keep aspect ratio
static public Bitmap scaleToFitHeight(Bitmap b, int height) {
float factor = height/(float) b.getHeight();
return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factor), height, false);
}
// Scale and keep aspect ratio
static public Bitmap scaleToFill(Bitmap b, int width, int height) {
float factorH = height/(float) b.getWidth();
float factorW = width/(float) b.getWidth();
float factorToUse = (factorH > factorW) ? factorW : factorH;
return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorToUse), (int) (b.getHeight() * factorToUse), false);
}
// Scale and dont keep aspect ratio
static public Bitmap strechToFill(Bitmap b, int width, int height) {
float factorH = height/(float) b.getHeight();
float factorW = width/(float) b.getWidth();
return Bitmap.createScaledBitmap(b, (int) (b.getWidth() * factorW), (int) (b.getHeight() * factorH), false);
}
}
내 질문은 :
- "실제 픽셀"을 피하는 이유는을 권장?
- 것은 내가이 방법 을 사용할 때 알고 있어야 내가 사용하는 방법 또는 무엇을 사용하는 단점은 무엇입니까 화면에 비트 맵을 확장의 가장 좋은 방법은 무엇 (환영 다음 더 많은 튜토리얼 의 좋은 기사입니다)입니다 귀하의 조언에 대한
감사
나는 (그것이 어떤 차이를 만들 경우) 나는 보통
[http] : //stackoverflow.com/a/823966/556337). 비트 맵 – teoREtik