【发布时间】:2023-03-26 04:07:01
【问题描述】:
我想开发一个应用程序,它可以拍照并允许您选择摄影框架。
我已经开发了接口,比如拍照和存储。
但我无法为拍摄的照片添加相框。
有什么推荐吗?
【问题讨论】:
标签: java android xamarin jboss iconic
我想开发一个应用程序,它可以拍照并允许您选择摄影框架。
我已经开发了接口,比如拍照和存储。
但我无法为拍摄的照片添加相框。
有什么推荐吗?
【问题讨论】:
标签: java android xamarin jboss iconic
您以什么格式存储拍摄的照片和相框图像?如果您打算将图片插入一个简单的框架中,我建议您先在Canvas 上绘制您拍摄的照片,然后在其上绘制您的框架。请记住尺寸 - 您不希望图片太小或太大。
我在这里提供一个示例 sn-p:
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;
}
请记住,我尚未测试代码,您可能(实际上,您必须)应用更正。
【讨论】:
感谢您的帮助,我提出了我的解决方案:
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);
}
【讨论】: