<span style="font-size:18px;"> Intent intent = new Intent(SendMicoBlog.this, RotaingActivity.class);
MyApp myApp = (MyApp)getApplication();
myApp.setName(bitmap);//修改之后的名称
myApp.setPhoto(isPhoto);
startActivityForResult(intent, 1);</span>
<span style="font-size:18px;"> //获取bitmap
MyApp myApp = (MyApp)getApplication();
bitmap = myApp.getName();
System.out.println("RotaingActivity w = " + bitmap.getWidth() + "H = " + bitmap.getHeight());
myBitmap = bitmap;
myWidth = bitmap.getWidth();
myHeight = bitmap.getHeight();
// 创建操作图片用的matrix对象
matrix = new Matrix();
Drawable drawable = ImageDispose.bitmapToDrawable(bitmap);
imageView.setBackgroundDrawable(drawable);
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
RotaingActivity.this.finish();
}
});
btnRightRotaing.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
myBitmap = rotaingImageView(-90);
}
});
btnLeftRotaing.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
myBitmap = rotaingImageView(+90);
}
});
btnOK.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
MyApp myApp = (MyApp)getApplication();
myApp.setName(myBitmap);//修改之后
System.out.println("OK resultcoder");
Intent intent = new Intent(RotaingActivity.this, SendMicoBlog.class);
setResult(6, intent);
RotaingActivity.this.finish();
}
});
}
private Bitmap rotaingImageView(int angle2) {
//旋转图片 动作
matrix.postRotate(angle2);
System.out.println("angle2=" + angle2);
// 创建新的图片
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
myWidth, myHeight, matrix, true);
Drawable drawable = ImageDispose.bitmapToDrawable(resizedBitmap);
imageView.setBackgroundDrawable(drawable);
return resizedBitmap;
}</span>
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inSampleSize = 8; File file = new File(SD_CARD_TEMP_DIR); /** * 获取图片的旋转角度,有些系统把拍照的图片旋转了,有的没有旋转 */ int degree = ImageDispose.readPictureDegree(file.getAbsolutePath());
<span style="font-size:18px;">Bitmap cameraBitmap = BitmapFactory.decodeFile(SD_CARD_TEMP_DIR, bitmapOptions); bitmap = cameraBitmap; /** * 把图片旋转为正的方向 */ bitmap = ImageDispose.rotaingImageView(degree, bitmap); upload(bitmap);</span>
<span style="font-size:18px;"> /**
* 旋转图片
* @param angle
* @param bitmap
* @return Bitmap
*/
public static Bitmap rotaingImageView(int angle , Bitmap bitmap) {
//旋转图片 动作
Matrix matrix = new Matrix();;
matrix.postRotate(angle);
System.out.println("angle2=" + angle);
// 创建新的图片
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
return resizedBitmap;
}</span>
/**
* 读取图片属性:旋转的角度
* @param path 图片绝对路径
* @return degree旋转的角度
*/
public static int readPictureDegree(String path) {
int degree = 0;
try {
ExifInterface exifInterface = new ExifInterface(path);
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
} catch (IOException e) {
e.printStackTrace();
}
return degree;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-3 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.yuanmawang.com) 版权所有