你能告诉我下面的代码有什么问题吗?我想并排显示2张图片,但结果位图只显示1张图片而不是2张合并的图片。
int width, height = 0;
width = UploadMorePictures.bitmapsList.get(0).getWidth()+ UploadMorePictures.bitmapsList.get(1).getWidth();
height = UploadMorePictures.bitmapsList.get(0).getHeight();
Log.d("usm_canvasSize","width="+width+" , height="+height);
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
try {
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(UploadMorePictures.bitmapsList.get(0), 0f, 0f, null);
int x = UploadMorePictures.bitmapsList.get(0).getWidth()+ UploadMorePictures.bitmapsList.get(1).getWidth();
int y = UploadMorePictures.bitmapsList.get(0).getHeight();
comboImage.drawBitmap(UploadMorePictures.bitmapsList.get(1), x, y, null);
picture_iv.setImageBitmap(cs);
答案 0 :(得分:1)
BitMap的左上角为(x,y)。所以你应该将x,y的计算替换为
int x = UploadMorePictures.bitmapsList.get(0).getWidth();
int y = 0;