Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Carrier: Verizon
Accepted Solution

Layered image not being created correctly.

[ Edited ]

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):

  1. Overlay
  2. Solid color masked object
  3. Scaled RGBA image also masked
  4. Drop shadow

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.

 

In summary:

  • Something is causing a white drawing/clearing of the background of the image.
  • The image is not showing up so I don't know if scaling and/or masking is working.
  • The solid color object is not showing up so I don't know if masking is working.
  • The to static images are getting serverly distorted and messed up.
  • All images are (supposed to) have alpha and the resulting image should have transperency.
  • All tests were done with Eclipse plugin 1.2, Component Pack 5.0.0.25, on the Storm 9550 simulator (with the very helpful hot swapping code).
---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Carrier: Verizon

Re: Layered image not being created correctly.

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?

 

Anything?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Carrier: Verizon

Re: Layered image not being created correctly.

[ Edited ]

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.

 

Not working:

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);

 

Working:

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).

 

Weird

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Carrier: Verizon

Re: Layered image not being created correctly.

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.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.