캔버스로 직접 할 수 없습니다. 그리기 전에 비트 맵 (매트릭스 사용)을 실제로 수정해야합니다. 다행히도 이렇게하는 것이 매우 간단한 코드입니다.
public enum Direction { VERTICAL, HORIZONTAL };
/**
Creates a new bitmap by flipping the specified bitmap
vertically or horizontally.
@param src Bitmap to flip
@param type Flip direction (horizontal or vertical)
@return New bitmap created by flipping the given one
vertically or horizontally as specified by
the <code>type</code> parameter or
the original bitmap if an unknown type
is specified.
**/
public static Bitmap flip(Bitmap src, Direction type) {
Matrix matrix = new Matrix();
if(type == Direction.VERTICAL) {
matrix.preScale(1.0f, -1.0f);
}
else if(type == Direction.HORIZONTAL) {
matrix.preScale(-1.0f, 1.0f);
} else {
return src;
}
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}
thanks @ aleks-g –
코드 스 니펫을 보내 주셔서 감사합니다. 뒤집은 이미지를 원했고 setImageResource를 사용하고 있었을 때, 간단히이 이미지 파일로 대체했습니다 : imageView.setImageBitmap (flip (BitmapFactory.decodeResource (getResources(), R.id.someimage), Direction.HORIZONTAL)); –
나는 이것이 아주 오래되었다는 것을 알고있다. 그러나 이것은 나의 베이컨을 막 저장했다. 감사! – LokiSinclair