有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法降低位图分辨率

你好,这个问题可能有点长,但我会解释所有的事情 得到了我已经试过的代码 我有一个应用程序里面有一个按钮内容:

try{

Intent Intent1 = new Intent(MainActivity.this , TheSsecondClass2.class);
Intent1.putExtra("bitmapsent", ImageMap); // from user gallery or camera 
startActivityForResult(Intent1, 3);
}

然后应用程序使“在新活动中”imageview等于ImageMap,并使用以下代码缩放Imageview

Captured.setImageBitmap(ImageMap);
    Captured.getLayoutParams().height = 1400;
    Captured.getLayoutParams().width = 1200;

然后用户对其进行一点编辑,然后在完成时使用按钮返回RESULT_OK及其代码:

            overlay(Background, currentleft, currentright, currentTop,currentBottom);
//          getting things back when the safr"startactivityforresult" starts

            Intent IntentBack = new Intent(TheSsecondClass2.this , MainActivity.class);
            IntentBack.putExtra("returnedbitmap", bmOverlay);
            IntentBack.putExtras(IntentBack);
            setResult(RESULT_OK , IntentBack);
            finish();

overlay方法返回位图bmoverlay是用于编辑目的(如编辑左、右)的位图的混合体 底部、顶部和背景或主图片位图合并到一个图像中的问题,一切都很好,但问题是 当它回来时,位图变得越来越大,甚至在将其添加到gallery时,它也会离开图像视图的边缘。我尝试使用以下方法对其进行缩放:

                ScaledBit = Bitmap.createScaledBitmap(ImageMap, 1, 1, true);
            ScaledBit = ImageMap;

使用-1或更大的数字,但这就像把它放大了1000倍左右。 并尝试了以下两种代码:

    CapturedImage.setMaxHeight(200);
            CapturedImage.setMaxHeight(200);
            Bitmap.setwidth();
            Bitmap.setHeight();

我可能会使用更多,但我忘记了,所有变量声明如下:

Bitmap ImageMap;
ImageView CapturedImage;
static Bitmap currentright,currentleft,currentTop,currentBottom;
static Bitmap bmOverlay ,background;

api 11级。 请帮忙,顺便说一句谢谢


共 (0) 个答案