android gpuimage中的视图旋转
我正在尝试从android gpuImage中旋转图像,但旋转不起作用。这是密码android gpuimage中的视图旋转,android,image-processing,rotation,android-gpuimageview,Android,Image Processing,Rotation,Android Gpuimageview,我正在尝试从android gpuImage中旋转图像,但旋转不起作用。这是密码 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_document_edit); mGPUImageView = (GPUImageView) findViewById(R.id.gpuimage
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_document_edit);
mGPUImageView = (GPUImageView) findViewById(R.id.gpuimage);
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, REQUEST_PICK_IMAGE);
seekBar = (SeekBar) findViewById(R.id.seekBar);
seekBar.setOnSeekBarChangeListener(this);
findViewById(R.id.btn_rotate).setOnClickListener(this);
findViewById(R.id.button_save).setOnClickListener(this);
GPUImageFilter filter = new GPUImageBrightnessFilter();
switchFilterTo(filter);
mGPUImageView.requestRender();
}
旋转按钮的OnClick方法:
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_rotate:
rotationAngle -= 90f;
if (rotationAngle <= -360f)
rotationAngle = 0f;
mGPUImageView.setRotationX(rotationAngle);
mGPUImageView.requestRender();
break;
}
}
@覆盖
公共void onClick(视图v){
开关(v.getId()){
案例R.id.btn\U旋转:
旋转角度-=90f;
如果(旋转角度int标志=0
public void setRotationRight() {
if (flag == 0) {
gpuImageView.setRotation(Rotation.ROTATION_90);
flag = 1;
AppConfig.log(TAG, "90, flag: " + flag);
} else if (flag == 1) {
gpuImageView.setRotation(Rotation.ROTATION_180);
flag = 2;
AppConfig.log(TAG, "180, flag: " + flag);
} else if (flag == 2) {
gpuImageView.setRotation(Rotation.ROTATION_270);
flag = 3;
AppConfig.log(TAG, "270, flag: " + flag);
} else if (flag == 3) {
gpuImageView.setRotation(Rotation.NORMAL);
flag = 0;
AppConfig.log(TAG, "normal, flag: " + flag);
}
}
public void setRotationLeft() {
if (flag == 0) {
gpuImageView.setRotation(Rotation.ROTATION_270);
flag = 1;
AppConfig.log(TAG, "270, flag: " + flag);
} else if (flag == 1) {
gpuImageView.setRotation(Rotation.ROTATION_180);
flag = 2;
AppConfig.log(TAG, "normal, flag: " + flag);
} else if (flag == 2) {
gpuImageView.setRotation(Rotation.ROTATION_90);
flag = 3;
AppConfig.log(TAG, "180, flag: " + flag);
} else if (flag == 3) {
gpuImageView.setRotation(Rotation.NORMAL);
flag = 0;
AppConfig.log(TAG, "90, flag: " + flag);
}
}
使用setRotation(Rotation.Rotation_90);而不是setRotationX(),并使用Rotation_180、Rotation_270探索更多内容