그림 크기 조정 방법
2182 단어 그림
public Bitmap ResizeBitmap(Bitmap bitmap, int newWidth) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float temp = ((float) height) / ((float) width);
int newHeight = (int) ((newWidth) * temp);
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// matrix.postRotate(45);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
bitmap.recycle();
return resizedBitmap;
}
코드 2:
public Bitmap resizeBitmap(Bitmap bitmap, int maxWidth, int maxHeight) {
int originWidth = bitmap.getWidth();
int originHeight = bitmap.getHeight();
// no need to resize
if (originWidth < maxWidth && originHeight < maxHeight) {
return bitmap;
}
int width = originWidth;
int height = originHeight;
// ,
if (originWidth > maxWidth) {
width = maxWidth;
double i = originWidth * 1.0 / maxWidth;
height = (int) Math.floor(originHeight / i);
bitmap = Bitmap.createScaledBitmap(bitmap, width, height, false);
}
// ,
if (height > maxHeight) {
height = maxHeight;
bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
}
// Log.i(TAG, width + " width");
// Log.i(TAG, height + " height");
return bitmap;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
최강의 도면 작성 도구는 '물건' 촬영이다. 게으른 엔지니어를 위한 그림술·설명술.장애물이 너무 높습니다. 우리 엔지니어에게는 그림 그리기·도면 작성 센스는 없다. 그래서 왜 그림의 게재, 도면 게재를 포기한 것인가. 어떤 그림 그리기 도구, 도면 작성 도구도 일장일단. MacBook은 그릴 수 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.