0

保存图像后,我的图像在画布内显得很小,而且还模糊并显示黑色背景。谁能告诉我为什么?

        Bitmap mBackground = Bitmap.createBitmap(myBitmap.getWidth() ,myBitmap.getHeight(),myBitmap.getConfig());

        mCanvas = new Canvas(mBackground);

        //mCanvas.drawBitmap(mBackImage, (mCanvas.getWidth() / 2), 0, null);
        mCanvas.drawBitmap(myBitmap ,mCanvas.getWidth(),mCanvas.getHeight(), null);
        mCanvas.drawBitmap(myBitmap1,x-dx,y-dy, null);

        try
        {
            mBitmapDrawable = new BitmapDrawable(mBackground);

            Bitmap mNewSaving = mBitmapDrawable .getBitmap();
            String ftoSave = mTempDir + mSaveImageName;
            File mFile = new File(ftoSave);
             Random generator = new Random();
                int n = 10000;
                n = generator.nextInt(n);
            FileOutputStream out = new FileOutputStream(mFile);

            mNewSaving.compress(CompressFormat.JPEG,0, out);
            Toast.makeText(getApplicationContext(), "Image Saved",Toast.LENGTH_SHORT).show();

            out.flush();
            out.close();

        }
4

1 回答 1

0

mNewSaving.compress(CompressFormat.JPEG,0, out);第二个参数中如下:

提示压缩机,0-100。0 表示压缩为小尺寸,100 表示压缩为最大质量。某些格式,例如无损的 PNG,将忽略质量设置

所以如果你想要一个大的图像,你应该把它100

mNewSaving.compress(CompressFormat.JPEG, 100, out);
于 2013-10-25T07:54:05.127 回答