问题描述
我正在尝试将图像拆分为多个部分,例如 16 个块 (4x4).
I am attempting to split an image into pieces, lets say for example 16 chunks (4x4).
我找到了很多java的例子,但Android没有BufferedImage,什么也没有……我想.
I have found so many examples with java, but Android does not have BufferedImage and what not... I think.
我有一个不错的想法,但我真的不知道从哪里开始.
I have a decent IDEA on how to, but I don't really know where to start.
我应该使用位图还是可绘制对象?
Should I use a bitmap or a drawable?
是否有拆分方法或者我必须制作自定义方法?
Is there a method to split or will I have to make a custom method?
我应该使用 GridView 来保存分割图像吗?
Should I use a GridView to hold the split images?
我不想给人以新手的印象,不想让别人为我做这件事,我想要自己做这件事的满足感,但我不知道从哪里开始,因为我是新手到 Java 和 Android 中的图形.
I don't want to com across as newbish and wanting to have someone do this for me, I want the satisfaction of doing it myself, but I don't have to much of an idea where to start since I am new to graphics in Java and Android.
希望我的大部分问题都能得到解答,甚至可能有一些我因某种原因找不到的示例.
Hopefully most of my questions are answerable and maybe even have examples available that I can't find for some reason.
推荐答案
我觉得你需要这个
void createImageArrays()
{
Bitmap bMap = BitmapFactory.decodeResource(getResources(), image);
Bitmap bMapScaled = Bitmap.createScaledBitmap(bMap, 240, 240, true);
bitmapsArray[0] = Bitmap.createBitmap(bMapScaled, 0, 0, 80, 80);
bitmapsArray[1] = Bitmap.createBitmap(bMapScaled, 80, 0, 80, 80);
bitmapsArray[2] = Bitmap.createBitmap(bMapScaled, 160, 0, 80, 80);
bitmapsArray[3] = Bitmap.createBitmap(bMapScaled, 0, 80, 80, 80);
bitmapsArray[4] = Bitmap.createBitmap(bMapScaled, 80, 80, 80, 80);
bitmapsArray[5] = Bitmap.createBitmap(bMapScaled, 160, 80, 80, 80);
bitmapsArray[6] = Bitmap.createBitmap(bMapScaled, 0, 160, 80, 80);
bitmapsArray[7] = Bitmap.createBitmap(bMapScaled, 80, 160, 80, 80);
bitmapsArray[8] = Bitmap.createBitmap(bMapScaled, 160, 160, 80, 80);
}
原图是240x240,我把它分成9块80x80
The original image is 240x240 and I divided it into 9 pieces of 80x80
这篇关于Android - 拆分 Drawable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!