私はView
今、それを修正サイズとして、たとえば500*666
SDカードに保存しようとしています。画像は正常に保存されますが、画像は次のように保存されます。画像は画像全体の隅に保存されます 添付画像をご覧ください。
コード :
private void onSave(final View v) {
v.setMinimumWidth(500);
v.setMinimumHeight(666);
Bitmap viewBitmap_save = null;
savingdialog();
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(
dm);
Display display = getWindowManager()
.getDefaultDisplay();
viewBitmap_save = Bitmap.createBitmap(500, 666,
Bitmap.Config.ARGB_8888);// i
Canvas canvas = new Canvas(viewBitmap_save);
v.draw(canvas);
try {
Random randomGenerator = new Random();
long RANDOMFILENUMBER = randomGenerator
.nextLong();
File wallpaperDirectory = new File(
"/sdcard/Image Telling/");
// have the object build the directory
// structure, if needed.
wallpaperDirectory.mkdirs();
// create a File object for the output file
// FileOutputStream outStream = new
// FileOutputStream(file);
File outputFile = new File(wallpaperDirectory,
RANDOMFILENUMBER + ".png");
FileOutputStream outStream = new FileOutputStream(
outputFile);
viewBitmap_save.compress(CompressFormat.PNG,
100, outStream);
sendBroadcast(new Intent(
Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://"
+ Environment
.getExternalStorageDirectory())));
} catch (Exception e) {
// TODO: handle exception
}
}
固定サイズの画像が必要なため、幅と高さを修正しています。ビューをスケーリングする方法?? 私を助けてください。