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

Web and WebWorks Development

Reply
Contributor
Posts: 32
Registered: ‎03-19-2012
My Device: developer
My Carrier: Reliance

Blakberry Image effect and controll

Hi I am new to blackberry and i am working on a project in which I am working with images.

i.e I want to change image effects like sepia,charcoal,grayscale,negative etc and edit options like changing

hue,saturation,contrast etc,

 

 I succeed in rotating(flip) the image.

I have tried it for other effects but cant able to find the answer.

 

Can u help me atleast on sepia and grayscale...plz rply

 

 

Code that i tried for gray scale the image-----

Suggest me the changes........

 

public Bitmap getGrayScaleImage(Bitmap image) {
        
        int[] argb = new int[image.getWidth() * image.getHeight()];

        image.getARGB(argb, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
        for (int i = argb.length - 1; i >= 0; --i)

    {// int alpha = argb[i] >> 24; int red = argb[i] >> 16 & 0xFF; int green = argb[i] >> 8 & 0xFF; int blue = 255-argb[i] & 0xFF;
            int alpha = argb[i] >> 24;
            int red = argb[i] >> 16 & 0xFF;
            
            int green = argb[i] >> 8 & 0xFF;
            int blue = argb[i] & 0xFF;

            int grey = ( red + green + blue ) / 3;
            red = grey;
            green = grey;
            red = grey;
            
            int newval = (alpha << 24) | (red << 16) | (green << 8) | blue;
            argb[i]=newval;
            greyScale.setARGB(argb, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
           // int  grey = (int) (0.3 * red + 0.59 * green + 0.11 * blue);

            int red2 = red * contrast/10+brightness;
            if (red2>0xFF) red2 = 0xFF;
            if (red2<0) red2 = 0;
            int green2 = green * contrast/10+brightness;
            if (green2>0xFF) green2 = 0xFF;
            if (green2<0) green2 = 0;
            int blue2 = blue * contrast/10+brightness;
            if (blue2>0xFF) blue2 = 0xFF;
            if (blue2<0) blue2 = 0;

            int composite = (alpha << 24) | (red << 16) | (green << 8) | blue|red|green;
            argb[i] = composite;
        }

        greyScale.setARGB(argb, 0, image.getWidth(), 0, 0, image.getWidth(), image.getHeight());
    
        return greyScale;
    }