开发者

Android: Canvas made out of multiple images won't save

开发者 https://www.devze.com 2023-02-18 03:12 出处:网络
Right my title isn\'t the best in the world. I\'ve got a big code that\'s supposed to make on big bitmap out of multiple bitmaps. I\'ve isolated the problem to this part of the code

Right my title isn't the best in the world. I've got a big code that's supposed to make on big bitmap out of multiple bitmaps. I've isolated the problem to this part of the code

bity = Bitmap.createBitmap(specialWidth,specialHeight,Bitmap.Config.ALPHA_8);
Canvas canvas = new Canvas(bity);

float left=0.0f;
for (int i = 0; i < imagesArrayz.length; i++开发者_如何学Go){

     float top=0.0f;        
     canvas.drawBitmap(imagesArrayz[i], left, top, null);
     left+=imagesArrayz[i].getWidth();
}

To explain: "bity" is a globally defined Bitmap object and it's unassigned untill this point;

imagesArrayz is an array of 5 Bitmaps that has already ben assigned and has ben assigned correctly (i tested it to see if each image is in the array)

After this i just have a function that saves the global variable bity to a file. THE PROBLEM is that instaid of saving my nicely drawn canvas it saves an empty jpg file of 0kb. Please help!


I answered my own question... Replace ALPHA_8 with ARGB_8888 and it all magically works.

Someone shoot me please...

0

精彩评论

暂无评论...
验证码 换一张
取 消