04-08-2010 09:52 PM - edited 04-08-2010 10:18 PM
I created a multi layer image that will be used to auto-generate a detailed image with static overlays, glow, and drop shadow. Something is not going right. I have a total of 4 layers, 2 are actual images, 2 are the generated images.
Order (top to bottom):
The overlay and drop shadow have alpha transparency, the other two are supposed to but something is not working on them. #2 seems never to get alpha so I end up losing #3 and 4.
I'll get back to that problem later, the next part is that even if all I do is draw the pre-created, static overlay and drop shadow the images are "lost". The correct result should be a white square with a drop shadow, the result is a distorted, chopped up, partially missing white square with no drop shadow. A different overlay that has glow is also applied to the original drop shadow, this turns out like a very overlit photo and barely anything can be seen except part of the shadow.
The two generated images don't show up at all. The first generated image is a Bitmap with alpha that gets scaled using the 5.0 Bitmap.scaleInto function running the Lanczos algorithm. This image then gets masked so that only part of the image shows. The second generated image is a solid, generated color (fillRect) that has the same masking application done to it. Both don't show up when drawn individually. They come out like white images as well.
Hopefully you can understand all that and I didn't confuse you.
Solved! Go to Solution.
04-09-2010 04:30 PM
Has anyone else had issues drawing multiple transparent images on top of each other? Scaling images with alpha (I know I have heard it but don't remember)? Experience with masking images? Using Graphics.rop?
04-09-2010 09:12 PM - edited 04-09-2010 09:52 PM
Ok part of the issue fixed, I couldn't get a transparent background so I did some searching and found one of my older posts. That fixed the white background.
Unfortunately I still get the distorted white rectangle, I realized that the drop shadow was being drawn on top of the image. The thing is the drop shadow is the image and a different image is drawn on top of that but it looks backwards.
Edit: Figured out why the one of the images wasn't working, well actually I don't know why it wasn't working but I know how to fix it. I have to take the data out and "reset" it.
Bitmap img = Bitmap.getBitmapResource(PATH); Graphics g = Graphics.create(img); g.drawBitmap(0, 0, img.getWidth(), img.getHeight(), Bitmap.getBitmapResource(PATH2), 0, 0); //This looks like I did this: Bitmap img = Bitmap.getBitmapResource(PATH2); Graphics g = Graphics.create(img); g.drawBitmap(0, 0, img.getWidth(), img.getHeight(), Bitmap.getBitmapResource(PATH), 0, 0);
Bitmap img = Bitmap.getBitmapResource(PATH); int data = new int[img.getWidth() * img.getHeight()]; img.getARGB(data, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); img = new Bitmap(Bitmap.ROWWISE_16BIT_COLOR, img.getWidth(), img.getHeight()); img.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP); img.setARGB(data, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); Graphics g = Graphics.create(img); g.drawBitmap(0, 0, img.getWidth(), img.getHeight(), Bitmap.getBitmapResource(PATH2), 0, 0);
(You can also use a seperate Graphics object instead of an array but I already have an array allocated for the transparency purpose).
04-09-2010 10:54 PM
OK last problems solved. I originally tried doing a manual loop to mask the images but thought that it would take too long
Also because of the pervious white background problem I thought it didn't work. I also thought that loop was the cause of the white background so I started looking for an alternative, saw rop and gave it a try. That didn't work no matter what I did so I worked on the static images.
Once I got those working I realized that rop was working, just not in the way I wanted. So I went back to the loops and that worked.