私は写真を撮ることができるカメラアプリを作ったが、特定の(プリセット)幅/高さとアスペクト比で保存したい。あらかじめ設定されたアスペクト比と幅/高さの画像をトリミングして保存する
例:
- レッド:古い絵(ソース)
- 緑:赤と緑の間に新しい画像
- :私が試したマージン
次の(運がない):
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bitmap = BitmapFactory.decodeFile(editPhotoFile.getAbsolutePath(), bmOptions);
bitmap = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), true);
Bitmap croppedBmp = Bitmap.createBitmap(bitmap, margin, margin, bitmap.getWidth() - margin, bitmap.getHeight() - margin);
私は左端(最初のマージン)と上端(2番目のマージン)、および全幅と高さに一定量のピクセルをカットするためにマージンを試しました。働いていない。
Githubにはいくつかのライブラリがありますが、画像を選択して編集することができます。手動編集は必要ありません。作図する余白をあらかじめ設定しておきます。
また、スタックオーバーフローのとちょうどチュートリアルをグーグルか見つけることによって、ここに可能な解決策は、私に運を与えることはありません。 検索クエリ:
のJavaアンドロイドクロップ画像私を助けることができる
のJavaアンドロイドクロップ画像のチュートリアル
?
ので、ユーザーが画像croping..portionを編集したくありませんか? – rafsanahmad007
私は自分自身でイメージを切り抜きたいので、イメージは各デバイスで同じ比率になります。一部のデバイスには3:4センサーがあり、その他のデバイスには9:16または16:9などがあります。それが理由。 –