黑莓图像的单色和负面影响

时间:2012-03-30 08:51:09

标签: blackberry java-me

 I am new for blackberry app development.just a week before I start BB development.I had a project on image effects and controll. Now I am facing problems in converting images to negative and monochrome effetcs.

我已尝试使用以下代码来产生负面影响。我有负面图像的输出。但我没有得到正确的图像背景...它显示我蓝色背景.....

   final static double GS_RED = 0.299;//globally declared
    final static double GS_GREEN = 0.587;
    final static double GS_BLUE = 0.114;

    public Bitmap changeToNegativeEffect(Bitmap bitmap) {

        int[] argbData = new int[bitmap.getWidth() * bitmap.getHeight()];
        int[] newargb = new int[bitmap.getWidth() * bitmap.getHeight()];
        bitmap.getARGB(argbData, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
        for ( int i = argbData.length-1; i >= 0; i--) 
        {

            A= 255 -argbData[i] >> 24;
            R= 255 -argbData[i] >> 16 & 0xFF;
            G= 255 -argbData[i] >> 8 & 0xFF;
            B= 255 -argbData[i] & 0xFF;

            //R = G = B = (int)(GS_RED * R + GS_GREEN * G + GS_BLUE * B);

            //int composite=(A << 24) | (R << 16) | (G << 8) | B;


            argbData[i] = (0xff000000 | R<< 16 | G << 8 | B );

            newargb[i] = argbData[i];

        }
        bitmap.setARGB(newargb, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
        return bitmap;
     }

0 个答案:

没有答案