Logo Search packages:      
Sourcecode: javamorph version File versions  Download package

static void javamorph::CMorphOperator::merge (  )  [inline, static, private]

Merge (left.pixel, right.pixel)->(result.pixel). Result depends on ratio value & both polygon matrixes.

Definition at line 176 of file CMorphOperator.java.

References left_pixel, left_point, left_ratio, ratio, result_pixel, result_point, right_pixel, right_point, and right_ratio.

Referenced by genResultTriangles(), and triangle().

                               {
        try{
            left_pixel = CConfig.left_image.getRGB
                (left_point.x, left_point.y);
            right_pixel = CConfig.right_image.getRGB
                (right_point.x, right_point.y);
            left_ratio = CConfig.left_clip[left_point.x][left_point.y];
            right_ratio = CConfig.right_clip[right_point.x][right_point.y];
            /* Unify all 3 ratios. */
            double
                t1 = left_ratio,
                t2 = 1.0 - left_ratio,
                t3 = 1.0 - right_ratio,
                t4 = right_ratio,
                fl = t3 + (1.0 - ratio) * (t1 - t3),
                fr = t2 + ratio * (t4 - t2);
            /* For each color in 32 bit color value. */
            int 
                l_r = ( left_pixel & 0xffff0000) >> 16,
                r_r = (right_pixel & 0xffff0000) >> 16,
                l_g = ( left_pixel & 0xff00ff00) >> 8,
                r_g = (right_pixel & 0xff00ff00) >> 8,
                l_b =   left_pixel & 0xff0000ff,
                r_b =  right_pixel & 0xff0000ff,
                r = (int)(l_r * fl + r_r * fr),
                g = (int)(l_g * fl + r_g * fr),
                b = (int)(l_b * fl + r_b * fr);
            /* Set pixel. */
            result_pixel = (0xff000000) | (r << 16) | (g << 8) | b;    
            CConfig.result_image.setRGB
                (result_point.x, result_point.y, result_pixel);
        }catch(Exception e){}
    }


Generated by  Doxygen 1.6.0   Back to index