欢迎来到天天文库
浏览记录
ID:37183294
大小:46.00 KB
页数:6页
时间:2019-05-21
《介绍图形图像处理的过程》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、介绍图形图像处理的过程 运用容易图片(赞成png/jpg/gif图片) 1.应用Drawable对象 2.Bitmap和BitmapFactory Bitmap代表一张位图,BitmapDrawable里封装的图片就是一个Bitmap对象。 Bitmap与BitmapDrawable之间的转换: a.BitmapDrawablebd=newBitmapDrawable(bitmap); b.Bitmapbitmap=bd.getBitmap(); Bitmap还兴许经由过程createB
2、itmap()[挖取、挖取进行Matrix变换、根据Bitmap.Config]和createScaledBitmap()[进行缩放]来获取新位图。 BitmapFactory是一个器材类,从不合本源阐发取得Bitmap decodeByteArray(byte[]b,intoffset,intlength):指定的字节数组综合。 decodeFile(StringpathName):从pathName指定的文件中分析、树立。 decodeFileDescriptor(FileDescriptorfd)
3、:从fd对应的文件中解析、构建。 decodeResource(Resourcer,intid):依照ID从指定资本中分析、创设。 decodeStream(InputStreamis):从指定输入流中综合、创立。 Bitmap的回收:isRecycled-()是否已回收;recycle()-胁迫收受接管本身。 要会见其他存储路子(SDCard)里面的图片,都必要凭借BitmapFactory。 ※获取/assets/目次下的全部文件: AssetManagerassets=getAsserts();
4、String[]files=assets.list(“”); InputStreamassetFile=assets.open(files[i]); 若是图片还未回收,先逼迫回收该图片: if(bitmapDrawable!=null&&!bitmapDrawable.getBitmap().isRecycled()){ ble.getBitmap().recycle();} 绘图 1.绘图的基础:Canvas、Paint等 Canvas的绘制方法[onDraw(Canvascanvas)]
5、draw------: clipRect():剪切一个矩形区域、clipRegion():裁剪指定区域。 rotate()/scale()/translate()对Canvas进行旋转、缩放、移动。 Paint:设置绘制风格(画笔颜色、画笔粗细、填充风格等) setARGB()/setColor():设置颜色setAlpha():设置透明度 setAntiAlias():是否抗锯齿setPathEffect(PathEffectpe):路径效果 setShader(Shadershader):画笔
6、的填充效果setShadowLayer():阴影 setStrokeWidth(floatwidth):画笔的笔触宽度 setStrokeJoin(Paint.Joinjoin):转弯处的连接风格 setStyle(Paint.Stylestyle):设置Paint的填充风格[STROKE/FILL] setTextAlign(Paint.Alignalign):设置绘制文本时的文字对齐方式 setTextSize(floattextSize):文字大小 setDither():防抖动setMa
7、skFilter(): EmbossMaskFilter: BlurMaskFilter: RectF 2.Path类 Pathp=newPath();p.moveTo();p.lineTo();p.lineTo();p.close() PathEffect定义绘制效果 ComposePathEffect CornerPathEffect DashPathEffect DiscretePathEffect PathDashPathEffect SunPathEffect Path.addRect(
8、RectFrectF,Path.Directiondir) Canvas.drawTextOnPath() 3.绘制游戏动画 定时器Timer(用Handler传递消息进行重绘) 通知View重绘可以调用invalidate(在UI线程中)或postInvalidate(在非UI线程中)。 NewTimer().schedule(newTimerTask(){ Publicvo
此文档下载收益归作者所有