create Tixing image - Android Media

Android examples for Media:Picture

Description

create Tixing image

Demo Code


//package com.java2s;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;

import android.graphics.Canvas;
import android.graphics.Color;

import android.graphics.Paint;
import android.graphics.Path;

public class Main {

    public static Bitmap createTixingimage(Bitmap bitmap, float leftlen,
            float rightlen) {
        int height = bitmap.getHeight();
        int width = bitmap.getWidth();
        Bitmap bitmapWithReflection = Bitmap.createBitmap(width, height,
                Config.ARGB_8888);// ww w.j a  v a  2  s.co m
        Canvas canvas = new Canvas(bitmapWithReflection);
        canvas.drawBitmap(bitmap, 0, 0, null);
        Paint paint = new Paint();
        paint.setColor(Color.WHITE);
        paint.setAlpha(15);
        Path path = new Path();
        path.moveTo(0, 0);
        path.lineTo(0, height * leftlen);
        path.lineTo(width, height * rightlen);
        path.lineTo(width, 0);
        path.close();
        canvas.drawPath(path, paint);
        return bitmapWithReflection;
    }
}

Related Tutorials