1

我想开发一个可以拍照并允许您选择摄影框架的应用程序。

我已经开发了接口,比如拍照和存储。

但我把一个框架给我拍的照片我不能。

有什么推荐吗?

4

2 回答 2

0

您以什么格式存储拍摄的照片和相框图像?如果您打算将图片插入一个简单的框架中,我建议您先在Canvas上绘制您拍摄的照片,然后在其上绘制您的框架。请记住尺寸 - 你不希望你的图片太小或太大。

我在这里提供了一个示例片段:

public Bitmap Output(Bitmap takenPhoto, Bitmap frameImage)
{        
    int width, height, x, y;
    height = ### // your desired height of the whole output image 
    width = ### // your desired width of the whole output image
    x = ### // specify indentation for the picture
    y = ###

    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(result);
    Paint paint = new Paint();

    c.drawBitmap(takenPhoto, x, y, paint); // draw your photo over canvas, keep indentation in mind (x and y)
    c.drawBitmap(frameImage, 0, 0, paint); // now draw your frame on top of the image

    return result;
}

请记住,我没有测试代码,您可能(实际上,您必须)应用更正。

于 2017-07-04T23:16:51.780 回答
0

感谢您的帮助,我提出了我的解决方案:

ImageView 结果;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Bitmap miBitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(miBitmap);
    Paint paint = new Paint();

    c.drawBitmap(drawableToBitmap(R.mipmap.ic_launcher), 500, 500, paint); // draw your photo over canvas, keep indentation in mind (x and y)
    c.drawBitmap(drawableToBitmap(R.drawable.silver_frame), 0, 0, paint); // now draw your frame on top of the image

    Resultado.setImageBitmap(miBitmap);
}
public Bitmap drawableToBitmap(int imagen){
    return BitmapFactory.decodeResource(getApplicationContext().getResources(), imagen);
}
于 2017-07-05T22:00:21.213 回答