2017-07-04 11 views

答えて

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; 
} 

は、私は、コードをテストしていない、あなたは修正を適用します(実際には、あなたがする必要があります)可能性があることに注意してください。助けのための

+0

こんにちは---> jpej形式やPNG形式でフレーム内の写真 - >フレームは簡単です - >私はそれが可能だかどうかを確認するために解決策を試してみましょう。..おかげで –

0

おかげで、私は私の解決策置く:

ImageViewのResultadoを。

@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); 
} 
関連する問題