标签:2d android surfaceview android-canvas map-edit
我试图将我所有的小图像(例如草,水和沥青等)整合到一个位图中.
我有一个像这样的数组:
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 };
所以基本上这是10 * 10
每个数字都是image(number).png的占位符
但是我如何将它们合并在一起?
//西蒙
解决方法:
好的,因此以下代码段应将两个图像并排合并.我不想外推10,但是我敢肯定您会自己找出for循环的.
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;
}
标签:2d,android,surfaceview,android-canvas,map-edit 来源: https://codeday.me/bug/20191012/1898595.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。