views:

34

answers:

0

i want to adding a watermark image and text to another image in android,the effect look like office word ,could everyone give me some give directions , Code snippets,or link and so on.i do:

 public class testWatermarkImage extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Resources res=this.getResources();
    Bitmap  watermark=BitmapFactory.decodeResource(res, R.drawable.a1); 
    Bitmap  src=BitmapFactory.decodeResource(res, R.drawable.icon);
    BitmapDrawable drawable = new BitmapDrawable(createBitmap(watermark,src));   


    findViewById(R.id.iv).setBackgroundDrawable(drawable);
}

private Bitmap createBitmap( Bitmap src, Bitmap watermark )
{

    if( src == null )
    {
        return null;
    }
    int w = src.getWidth();
    int h = src.getHeight();
    int wh = watermark.getHeight();
    int ww = watermark.getWidth();
    Bitmap newb = Bitmap.createBitmap( w, h, Config.ARGB_8888 );
    Canvas cv = new Canvas( newb );
    cv.drawBitmap( src, 0, 0, null );
    cv.drawBitmap( watermark, w - ww + 5, h - wh + 5, null );
    cv.save( Canvas.ALL_SAVE_FLAG );
    cv.restore();
    return newb;
}}

my result only to mix two pictures,How to have a feeling of embedded