开发者

Android Need to set image from gallery as paint canvas background

I want to set an image from gallery as a background to the canvas in fingerpaint (api demo sample). I can retrieve the image from gallery b开发者_如何转开发ut not able to set that as a background. One guess is I can open the image as a input stream, convert that as a array and pass it for bitmap - but I am not sure whether it will work or not and i don't have any clue for how the code will be. Can somebody help me?


You can modify the onSizeChanged() function to,

    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        BitmapFactory.Options decode_options = new BitmapFactory.Options();

        decode_options.inMutable = true;
        mBitmap = BitmapFactory.decodeFile(<file_path>,decode_options);
        mCanvas = new Canvas(mBitmap);
        mBitmapPaint.setXfermode(new PorterDuffXfermode (SRC_IN));
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜