Home
JavaEE
Java GUI
Framework
DHtml
Android
插画
留言本
  • s60v3的6120c与蓝牙耳机nokia BH-320的配对连接方法
  • 三月雨后大王山下娇艳欲滴的杜鹃
  • 必须转载的一篇非常感人的文章!
  • Android中,Drawable接口及其子类的使用方法
  • 哈哈,老婆怀上了!婚礼不变,还是在正月十二!
  • Android中AnimationDrawable实现简单动画的例子
  • Android游戏开发中对象移动的例子
  • 用Handler重画和移动View的方法
  • Animation与Interpolator及AnimationSet的用法
  • 用LiveAndroid来调试运行Android的apk程序
  • 在客户端IE中使用jasperView,客户端显示JasperViewer
  • jspsmartupload取得参数的值是乱码的问题
  • 客户端显示JasperViewer并在Jasperview的applet中加超链接
  • Hibernate基于链接表的多对多many-to-many双向关联例子
  • Hibernate双主键的设置例子
  • Hibernate中的properties和formula的用法
  • Android中,Drawable接口及其子类的使用方法
  • Android中用Bitmap获取图片中某个区域的图象
  • Android中AnimationDrawable实现简单动画的例子
  • Animation与Interpolator及AnimationSet的用法
Android中用Bitmap获取图片中某个区域的图象
posted by David Chen at May 6, 2009, 5:22 PM

一般来说,一个JPG或PNG图象可能包括有几个部份(比如小狗跑步的起步,第一步,第二步)组成,
要分割出来,可以用Bitmap来做。

Bitmap p = BitmapFactory.decodeResource(context.getResources(), R.drawable.dog);
Log.d("Bitmap p", "" + p.getWidth() + " " + p.getHeight());
Bitmap p1 = Bitmap.createBitmap(p, 0, 0, 35, 26);
new BitmapDrawable(p1);
// 从p这个图中的点左上角(0,26)到点右下角(35,0)中的矩形图象

Rect (int left, int top, int right, int bottom)
the caller must ensure that left <= right and top <= bottom
left The X coordinate of the left side of the rectagle
top The Y coordinate of the top of the rectangle
right The X coordinate of the right side of the rectagle
bottom The Y coordinate of the bottom of the rectangle
即是左上角为坐标原点,左上角(left,top)的点与右下角(right,bottom)的点

Bitmap.createBitmap(p, left, top, width, height);
这个的width,height和上面的Rect的right,bottom参数是不同的,
Labels:   Java    Android  
Trackback:   http://cwq.iou1314.com/android-bitmap_a358
本站内的任何文章,只代表个人意见或学习所用,如有版权声明,请尊重作者的劳动成果,在转载时请保留原始链接并注明出处。
© 2007 - 2010 CWQ.IOU1314.COM All Rights Reserved.