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
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL
Accepted Solution

ROP Conastants for a specfic workflow

Hi,

 

I am doing the blending on the two images. Blending should happen such a way that, if there is a source pixel other than white it should be drawn onto the destination without any blending. If there is white pixel in the source and there is a destination pixle which has some color other than white, destination pixel should not be disturbed.

 Basically what i need is if there is some area of the source image with the white pixel, that should not overwrite the destination pixel. All other area should be like regular source copy.

 

I am looking for a specific rop constant for this operation.

 

orgGraphics.rop(Graphics.ROP2_DSa, x, y  ,ropBmp.getWidth(), ropBmp.getHeight(), ropBmp,x, y);

 

works fine, but it also blends two colors even though the source is non white.

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: ROP Conastants for a specfic workflow

I also don't understand exactly what you want. From your description, I came up with this:

 

source non white, dest non white => source

source non white, dest white => source

source white. dest non white => dest

source white, dest white => ?

 

If the '?' should be dest (or white), then this seems more like a ROP_SRCMONOEXPAND_COPY using the non-white part of the source as the mask. It doesn't sound like a blend at all.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: ROP Conastants for a specfic workflow

Your understanding of my problem is perfect. How to mention the non white part of the source as mask?

 

I just replaced my ROP call as given below, it is not working

 

orgGraphics.rop(Graphics.ROP_SRCMONOEXPAND_COPY, x, y  ,ropBmp.getWidth(), ropBmp.getHeight(), ropBmp,x, y);

Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: ROP Conastants for a specfic workflow

[ Edited ]

My source & destination bitmaps are color bitmaps. After changing to the ROP constant u mentioned, i just got white everywhere.

 

I am looking for simillar implementation of the AlphaComposite.SRC_OVER set to  graphics2d class in regular java

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: ROP Conastants for a specfic workflow

After a little sleep, I see now that using ROP_SRCMONOEXPAND_COPY was not my brightest suggestion. It uses a monochrome bitmap as a mask to draw the foreground color--kind of a stamp. Not at all what you want.

 

It seems to me that you want to draw the the source image as if it were fully transparent at its white pixels. I think the easiest way to do that is to create such an image from the source. Perhaps something like this (totally untested) will work:

 

int OPAQUE_WHITE = 0xffffffff;
int TRANSPARENT_WHITE = 0x00ffffff;
int w = src.getWidth();
int h = src.getHeight();
int [] pixels = new int[w * h];
src.getARGB(pixels, 0, w, 0, 0, w, h);
for (int i = 0; i < pixels.length; ++i) {
if (pixels[i] == OPAQUE_WHITE) pixels[i] = TRANSPARENT_WHITE;
}
Bitmap src2 = new Bitmap(Bitmap.ROWWISE_16BIT_COLOR, w, h);
src2.createAlpha(Bitmap.ALPHA_BITDEPTH_MONO);
src2.setARGB(pixels, 0, w, 0, 0, w, h);

Then simply use drawBitmap with src2 into/over dest. If I got the logic right, the white areas of src2 ought to not draw.

 

I don't know if creating a new image from src is going to cause a big performance hit. Perhaps you can cache src2 if the same src image is reused.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: ROP Conastants for a specfic workflow

Sounds nice idea. Let me try it today. I will update you with the solution.

Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: ROP Conastants for a specfic workflow

Thanks. It works Smiley Happy

Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: ROP Conastants for a specfic workflow

[ Edited ]

Thanks.

Highlighted
Regular Contributor
Posts: 69
Registered: ‎04-05-2010
My Device: Storm
My Carrier: BSNL

Re: ROP Conastants for a specfic workflow

 Ted,

 

It was a valuable information you gave,  please can you look into my other post

 

http://supportforums.blackberry.com/t5/Java-Development/ROP-SRC-COPY-with-the-drawTexturedPath/td-p/...

 

Thanks