Android中图形截取的方式介绍

本文介绍了在Android应用中如何进行图形截图,特别是通过Bitmap类实现任意截取图像的操作,帮助开发者掌握这一核心技术。
摘要由CSDN通过智能技术生成

在Android的应用中,有时候我们想只显示一部分图像,这时候就要求图形截图。

1、任意截取图像的方法,下面我们详细介绍一下android中的重要类——Bitmap

public final class

Bitmap

extends  Object
implements  Parcelable
java.lang.Object
  android.graphics.Bitmap

下面是Bitmap的所有应用方法,我们要熟悉记住:
公有方法
boolean compress( Bitmap.CompressFormat format, int quality,  OutputStream stream)
Write a compressed version of the bitmap to the specified outputstream.
Bitmap copy( Bitmap.Config config, boolean isMutable)
Tries to make a new bitmap based on the dimensions of this bitmap, setting the new bitmap's config to the one specified, and then copying this bitmap's pixels into the new bitmap.
void copyPixelsFromBuffer( Buffer src)
Copy the pixels from the buffer, beginning at the current position, overwriting the bitmap's pixels.
void copyPixelsToBuffer( Buffer dst)
Copy the bitmap's pixels into the specified buffer (allocated by the caller).
static  Bitmap createBitmap( Bitmap source, int x, int y, int width, int height,  Matrix m, boolean filter)
Returns an immutable bitmap from subset of the source bitmap, transformed by the optional matrix.
static  Bitmap createBitmap(int width, int height,  Bitmap.Config config)
Returns a mutable bitmap with the specified width and height.
static  Bitmap createBitmap( Bitmap source, int x, int y, int width, int height)
Returns an immutable bitmap from the specified subset of the source bitmap.
static  Bitmap createBitmap(int[] colors, int offset, int stride, int width, int height,  Bitmap.Config config)
Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.
static  Bitmap
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值