Android的 - 斯普利特绘制对象 [英] Android - Split Drawable
问题描述
我试图将图像分割成块,可以说,例如16块(4×4)。
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?
我不希望传达给COM的newbish并希望有人帮我这个忙,我希望做我自己满意的,但我没有得多一个想法从哪里开始,因为我是新以图形的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个80×80的
The original image is 240x240 and I divided it into 9 pieces of 80x80
这篇关于Android的 - 斯普利特绘制对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!