自定义图像,继承view,实现ondraw()方法
实现位图的三种常用方法:
用BitmapFactory解析图片 // --> 使用BitmapFactory解析图片 public void myUseBitmapFactory(Canvas canvas){ // 定义画笔 Paint paint = new Paint(); // 获取资源流 Resources rec = getResources(); InputStream in = rec.openRawResource(R.drawable.haha); // 设置图片 Bitmap bitmap =BitmapFactory.decodeStream(in); // 绘制图片 canvas.drawBitmap(bitmap, 0,20, paint); } 二、使用BitmapDrawable解析图片 // --> 使用BitmapDrawable解析图片 public void myUseBitmapDrawable(Canvas canvas){ // 定义画笔 Paint paint = new Paint(); // 获得资源 Resources rec = getResources(); // BitmapDrawable BitmapDrawable bitmapDrawable = (BitmapDrawable) rec.getDrawable(R.drawable.haha); // 得到Bitmap Bitmap bitmap = bitmapDrawable.getBitmap(); // 在画板上绘制图片 canvas.drawBitmap(bitmap, 20,120,paint); } 三、使用InputStream和BitmapDrawable绘制 // --> 使用InputStream和BitmapDrawable解析图片 public void myUseInputStreamandBitmapDrawable(Canvas canvas){ // 定义画笔 Paint paint = new Paint(); // 获得资源 Resources rec = getResources(); // InputStream得到资源流 InputStream in = rec.openRawResource(R.drawable.haha); // BitmapDrawable 解析数据流 BitmapDrawable bitmapDrawable = new BitmapDrawable(in); // 得到图片 Bitmap bitmap = bitmapDrawable.getBitmap(); // 绘制图片 canvas.drawBitmap(bitmap, 100, 100,paint); }
引用自定义标签的两种方式:
<com.fxhy.stady.HelloView android:layout_width="fill_parent" android:layout_height="wrap_content" /> <view class="com.fxhy.stady.HelloView" android:layout_width="fill_parent" android:layout_height="wrap_content" />
相关推荐
eoeAndroid特刊第二期:Android图像处理篇 pdf,eoeAndroid策划的第二篇专题,主要整理和翻译在Android中进行图像处理的一些资源和文章,通过本专题内容的学习,您可以掌握如何在Android上对图片编程,主要包括但不...
Android绘图机制与处理技巧(三)——Android图像处理之图形特效处理
本文是结合博客http://blog.csdn.net/eastmount/article/details/41668583关于android图像增强处理的。通过点击“打开图片”按钮选择本地图像,再通过3SeekBar按钮实现滑动修改图片的饱和度、色相和亮度。 免费资源...
Android图像处理之图形特效处理
Android图像处理技术(实现Android中的PS)(五)相关代码Demo: 博客地址:http://blog.csdn.net/nsgsbs
Android 图像增强 包含高斯、椒盐、speckle三种噪声的添加 包含均值滤波、中值滤波、低通滤波三种去噪滤波器
一款Android下的图像处理软件,功能强大,最重要的是支持手写,笔画
android 图像预览查看源码,支持图片放大、缩小、滚动等。 PhotoView-master.zip ## Features - Out of the box zooming, using multi-touch and double-tap. - Scrolling, with smooth scrolling fling. - Works ...
基于OpenCV+JAVA+C++的Android图像处理工具软件+源码+开发文档说明+实用教程,适合毕业设计、课程设计、项目开发。项目源码已经过严格测试,可以放心参考并在此基础上延申使用~ 基于OpenCV+JAVA+C++的Android图像...
android图像识别数据包,OCR图像识别,包括中文和英文
android 图像浏览实例.欢迎大家下载学习
android 图像滤镜处理 有十多种效果 Demo
Android图像介绍-Drawable
Android图像处理技术
android图像各种处理特效,很不错的代码,希望不要错过
Android 图像冰冻特效源码
android图像处理系统1.0
Android图像介绍-Bitmap常用操作
Android 图像连环画特效源码
Android 图像柔化美白特效源码