在Android的应用中,有时候我们想只显示一部分图像,这时候就要求图形截图。
1、任意截取图像的方法,下面我们详细介绍一下android中的重要类——Bitmap
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