从图像问题裁剪矩形

时间:2016-05-01 09:33:06

标签: android ios image bitmap

我需要使用此面具从横向拍摄照片(捕捉全屏):

enter image description here

然后从图像裁剪矩形,如下所示: enter image description here

我有一些裁剪问题。 我做(android):

grep Alpha output.dat | cut -d'=' -f2 | cut -d'.' -f1 > ./$run_dir/Alpha
grep Beta output.dat | cut -d'=' -f2 | cut -d'.' -f1 > ./$run_dir/Beta
grep flap output.dat | cut -d'=' -f2 > ./$run_dir/flap_angle
grep CLtot output.dat | cut -d'=' -f2 > ./$run_dir/CLtot
grep CYtot output.dat | cut -d'=' -f2 | cut -c-10 > ./$run_dir/CYtot
grep Cltot output.dat | cut -d'=' -f3 | cut -c-10 > ./$run_dir/Cltot
grep Cmtot output.dat | cut -d'=' -f3 | cut -c-10 > ./$run_dir/Cmtot
grep Cntot output.dat | cut -d'=' -f3 | cut -c-10 > ./$run_dir/Cntot
ls -tr ./$run_dir > ./$run_dir/files_string
cd ./$run_dir
octave ../assemble_matrix.m

iphone:

public Bitmap getCropImage() {

    Bitmap bitmap = getBitmap();
    int captureBitmapWidth = bitmap.getWidth();
    int captureBitmapHeight = bitmap.getHeight();

    // to get a multiplicative factor of axises.
    float xCoefficient = captureBitmapWidth / 720.0;
    float yCoefficient = captureBitmapHeight / 480.0;

    int cropRectangleWidth = 200;
    int cropRectangleHeight = 100;
    int cropRectangle_a_x = 200;
    int cropRectangle_a_y = 300;

    bitmap = Bitmap.createBitmap(bitmap,
            Math.round(cropRectangle_a_x * xCoefficient),
            Math.round(cropRectangle_a_y * yCoefficient),
            Math.round(cropRectangleWidth * xCoefficient),
            Math.round(cropRectangleHeight * yCoefficient));

    return bitmap;
}

在某些移动设备上,我得到了正确的结果,而其他裁剪矩形向下移动到左侧。错误在哪里?

1 个答案:

答案 0 :(得分:0)

我的猜测是你的代码问题在于你总是使用720x480,不同的Android设备总是如此。

也许更喜欢:

public ActionResult Action()
  {
    return Redirect(Request.UrlReferrer.PathAndQuery);
  }