import android.content.Context;import android.graphics.Bitmap;import android.graphics.Bitmap.Config;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.Paint.Style;import android.util.Log;import android.view.View;class DrawCG extends View {private static final String tag = "DrawCG";private Paint paint;private Canvas canv;private Bitmap mBitmap;// private EditText r1;// private EditText g1;// private EditText b1;public DrawCG(Context context, int width, int height) {super(context);// 声明画笔paint = new Paint();// 设置颜色paint.setColor(Color.RED);// 设置抗锯齿paint.setAntiAlias(true);// 设置线宽paint.setStrokeWidth(3);// 设置非填充paint.setStyle(Style.STROKE);// 声明位图mBitmap = Bitmap.createBitmap(width, height, Config.ARGB_);// 声明画布canv = new Canvas(mBitmap);}@Overrideprotected void onDraw(Canvas canvas) {canvas.drawBitmap(mBitmap, 0, 0, null);// super.onDraw(canvas);}/*** RED* * @return*/public Bitmap drawRed() {// canv.drawLine(, , , , paint);// canv.drawARGB(,3, 3, 3);canv.drawColor(Color.RED);return mBitmap;}/*** blue* * @return*/public Bitmap drawBlue() {canv.drawColor(Color.BLUE);return mBitmap;}/*** green* * @return*/public Bitmap drawGreen() {// canv.drawRect(new Rect(, , , ), paint);canv.drawColor(Color.GREEN);return mBitmap;}/** black*/public Bitmap drawBlack() {// canv.drawRect(new Rect(, , , ), paint);canv.drawColor(Color.BLACK);return mBitmap;}/** white **/public Bitmap drawWhite() {// canv.drawRect(new Rect(, , , ), paint);canv.drawColor(Color.WHITE);return mBitmap;}/** 灰阶 **/public Bitmap paintBitmap(int r, int g, int b) {Log.e(tag, "调用画图的方法,这里传入参数, r-->" r "| g--->" g "|b--->" b);canv.drawRGB(r, g, b);return mBitmap;}/** 灰阶 **/public Bitmap Onehuijie(int r, int g, int b) {Log.e(tag, " 4*灰阶调用");// canv.drawARGB(, 4 * r - 1, 4 * g - 1, 4 * b - 1);if ((r == ) | (g == ) |( b == )) {canv.drawRGB(, , );Log.e(tag, "r ,g ,b 的都是 , , ");}else {canv.drawRGB(4 * r , 4 * g , 4 * b);Log.e(tag, "灰阶计算执行,(4*r):"(4*r)"(4*g):"(4*g)"(4*b):"(4*b));}return mBitmap;}/** 外围白,中心黑**/public Bitmap BB(float left, float top, float right, float bottom) {Log.e(tag, "外围白,中心黑class");canv.drawColor(Color.WHITE);Paint paint = new Paint();paint.setColor(Color.BLACK); // 设置画笔颜色paint.setStyle(Style.FILL);// 设置填充样式paint.setStrokeWidth();// 设置画笔宽度// canv.drawRect(, , , , paint);// canv.drawRect(left / 8, top / 4, right * 7 / 8, bottom * 3 / 4,// paint);// 直接构造canv.drawRect(left / 4, top / 4, right * 3 / 4, bottom * 3 / 4, paint);// 直接构造return mBitmap;}public Bitmap Bh(float left, float top, float right, float bottom) {Log.e(tag, "外围白,中心huiclass");canv.drawColor(Color.WHITE);Paint paint = new Paint();paint.setColor(Color.rgb(, , )); // 设置画笔颜色paint.setStyle(Style.FILL);// 设置填充样式paint.setStrokeWidth();// 设置画笔宽度canv.drawRect(left / 4, top / 4, right * 3 / 4, bottom * 3 / 4, paint);// 直接构造return mBitmap;}public Bitmap BJ(float left, float top, float right, float bottom) {Log.e(tag, "外围灰色,中心白class");canv.drawColor(Color.rgb(, , ));Paint paint = new Paint();paint.setColor(Color.WHITE); // 设置画笔颜色paint.setStyle(Style.FILL);// 设置填充样式paint.setStrokeWidth();// 设置画笔宽度canv.drawRect(left / 4, top / 4, right * 3 / 4, bottom * 3 / 4, paint);// 直接构造return mBitmap;}public Bitmap BK(float left, float top, float right, float bottom) {Log.e(tag, "外围灰色,中心blackclass");canv.drawColor(Color.rgb(, , ));Paint paint = new Paint();paint.setColor(Color.BLACK); // 设置画笔颜色paint.setStyle(Style.FILL);// 设置填充样式paint.setStrokeWidth();// 设置画笔宽度canv.drawRect(left / 4, top / 4, right * 3 / 4, bottom * 3 / 4, paint);// 直接构造return mBitmap;}}
推荐整理分享drawpaint的类方法(drawand paint),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:drawand paint,draw paintings,draw方法的实现,drawand paint,draw paint,drawpie方法绘制的图形是,draw paint,draw paint,内容如对您有帮助,希望把文章链接给更多的朋友!
版权声明:本文为博主原创文章,未经博主允许不得转载。
高级控件AdapterView(一):Adapte继承体系及BaseAdapter 一、适配器接口Adapter继承体系Adapt是一个接口,是联通多条目控件AdaptView(ViewGroup是其父类,ListView、GridView、SpinnerView是其子类)与数据集的桥梁,主
android 开源项目GuillotineMenu,酷炫的铡刀菜单 开源项目GuillotineMenu使用指南先上效果图:IDE使用的是Androidstudio.首先下载GuillotineMenu项目的library引用到项目中,下载地址:
Android:Layout_weight 随录 Layout_weight属性的作用:它是用来分配属于空间的一个属性,你可以设置他的权重。很多人不知道剩余空间是个什么概念,下面我先来说说剩余空间。看