伙计们,我有一个解决方案可以从 5 个不同的另一个中创建一个位图。但是,我希望这个解决方案更快。我找不到另一种简单快捷的方法来做同样的事情。
private void createImage() {
// Magic numbers from image files
int numberOfImages = 5;
int imgWidth = 125;
int imgHeight = 300;
int totalwidth = imgWidth * numberOfImages;
int totalheight = imgHeight;
img = Bitmap.createBitmap(totalwidth, totalheight, Bitmap.Config.ARGB_8888);
for (int i = 0; i < numberOfImages; i++) {
Bitmap imgFile = BitmapFactory.decodeResource(context.getResources(), context.getResources().getIdentifier(
"f" + i, "drawable", context.getPackageName()));
for (int x = 0; x < imgWidth; x++) {
for (int y = 0; y < imgHeight; y++) {
int targetX = x + (i * imgWidth);
int targetY = y;
int color = imgFile.getPixel(x, targetY);
img.setPixel(targetX, targetY, color);
}
}
}
img = Bitmap.createScaledBitmap(img, screenWidth, screenHeight, true);
}