由网友(遮不住的悲伤)分享简介:我试着让我的所有小图像,例如草,水和沥青等,为一个位图。Im trying to get all my small images like grass, water and asphalt and so on, into one bitmap.我有一个是这样的一个数组:I have an Array that g...
我试着让我的所有小图像,例如草,水和沥青等,为一个位图。
Im trying to get all my small images like grass, water and asphalt and so on, into one bitmap.
我有一个是这样的一个数组:
I have an Array that goes like this:
public int Array[]={3, 1, 3, 3, 1, 1, 3, 3, 3, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1 ,1 ,1, 1, 1 ,1 ,1
,7 ,7 ,7, 7, 7 ,7, 7 ,7 ,7, 7
,7 ,7 ,7 ,7, 7 ,7, 7 ,7 ,7 ,7
,7 ,7 ,7 ,7, 7, 7, 7, 7 ,7 ,7
,7 ,7 ,7 ,7, 7, 7 ,7 ,7 ,7 ,7
,7 ,7 ,7 ,7, 7, 7, 7 ,7 ,7, 7
,6, 6, 6, 6, 6 ,6 ,6, 6, 6 ,6
,6, 6, 6 ,6, 6, 6 ,6, 6 ,6 ,6 };
所以basicly这是一个10 * 10 每一个数字是一个占位符图像(数字)巴纽
So basicly this is a 10*10 Every number is a placeholder for a image(number).png
但我怎么把它们合并起来?
But how do i merge them together?
//西门
推荐答案
好了,下面的代码片段应结合两个图像并排。我不想推断为10,但我敢肯定,你会弄明白的for循环自己。
Okay so the following snippet should combine two images side by side. I didn't want to extrapolate for 10, but I'm sure you'll figure out the for loops by yourself.
public Bitmap combineImages(Bitmap c, Bitmap s) {
Bitmap cs = null;
int width, height = 0;
if(c.getWidth() > s.getWidth()) {
width = c.getWidth() + s.getWidth(;
height = c.getHeight());
} else {
width = s.getWidth() + s.getWidth();
height = c.getHeight();
}
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(c, 0f, 0f, null);
comboImage.drawBitmap(s, c.getWidth(), 0f, null);
//notice that drawing in the canvas will automagically draw to the bitmap
//as well
return cs;
}
相关推荐
最新文章