Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4274952

ROIShape.add(ROIShape r) yields incorrect ROI

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      1.2.2
    • CPU:
      generic
    • OS:
      generic

      Description


      ROIShape.add(ROIShape r) yields incorrect ROI. This also occurs on subtract,
      intersect and other methods. Below are the affected JCK test cases:

      ROIShape/Intersects_R_22
      ROIShape/Intersects_R_23
      ROIShape/Intersects_i4_21
      ROIShape/Intersect_R_19
      ROIShape/Transform_A_25
      ROIShape/ROIShape_A_2
      ROIShape/Add_R_3
      ROIShape/ExclusiveOr_R_12
      ROIShape/Subtract_R_24

      The provided program at the end of this description produce the following
      output on jai_1.0.1:

      r1 = new ROIShape(s1) where s1 occupies the region:
       # # # -
       # # # -
       # # # -
       - - - -
      r2 = new ROIShape(s2) where s2 occupies the region:
       - - - -
       - # # #
       - # # #
       - # # #
      r3 = r2.add(r1) and expect the region:
       # # # -
       # # # #
       # # # #
       - # # #
      r3 = r2.add(r1) got the actual region:
       - # # -
       - # # -
       - # # #
       - - # #
      r3 = r2.subtract(r1) and expect the region:
       - - - -
       - - - #
       - - - #
       - # # #
      r3 = r2.subtract(r1) got the actual region:
       - - - -
       - - - -
       - - - -
       - - # -
      r3 = r2.intersect(r1) and expect the region:
       - - - -
       - # # -
       - # # -
       - - - -
      r3 = r2.intersect(r1) got the actual region:
       - - - -
       - - # -
       - - # #
       - - - -

      The program below demonstrates such behaviour:

      import java.awt.Shape;
      import java.awt.Rectangle;
      import javax.media.jai.ROIShape;
      import javax.media.jai.ROI;

      public class Bug_ROIShape_Drop_Pixels {

        public static void main(String args[]) {
          ROI r3;
          String str;

          Shape s1 = new Rectangle(0, 0, 3, 3);
          ROIShape r1 = new ROIShape(s1);
          System.out.println("r1 = new ROIShape(s1) where s1 occupies the region:");
          System.out.println(" # # # -");
          System.out.println(" # # # -");
          System.out.println(" # # # -");
          System.out.println(" - - - -");

          Shape s2 = new Rectangle(1, 1, 3, 3);
          ROIShape r2 = new ROIShape(s2);
          System.out.println("r2 = new ROIShape(s2) where s2 occupies the region:");
          System.out.println(" - - - -");
          System.out.println(" - # # #");
          System.out.println(" - # # #");
          System.out.println(" - # # #");

          r3 = r2.add(r1);
          System.out.println("r3 = r2.add(r1) and expect the region:");
          System.out.println(" # # # -");
          System.out.println(" # # # #");
          System.out.println(" # # # #");
          System.out.println(" - # # #");

          System.out.println("r3 = r2.add(r1) got the actual region:");
          for(int y = 0; y < 4; y++) {
            str = "";
            for(int x = 0; x < 4; x++) {
              if(r3.contains(x, y) == true)
                str = str + " #";
              else
                str = str + " -";
            }
            System.out.println(str);
          }

          r3 = r2.subtract(r1);
          System.out.println("r3 = r2.subtract(r1) and expect the region:");
          System.out.println(" - - - -");
          System.out.println(" - - - #");
          System.out.println(" - - - #");
          System.out.println(" - # # #");

          System.out.println("r3 = r2.subtract(r1) got the actual region:");
          for(int y = 0; y < 4; y++) {
            str = "";
            for(int x = 0; x < 4; x++) {
              if(r3.contains(x, y) == true)
                str = str + " #";
              else
                str = str + " -";
            }
            System.out.println(str);
          }

          r3 = r2.intersect(r1);
          System.out.println("r3 = r2.intersect(r1) and expect the region:");
          System.out.println(" - - - -");
          System.out.println(" - # # -");
          System.out.println(" - # # -");
          System.out.println(" - - - -");

          System.out.println("r3 = r2.intersect(r1) got the actual region:");
          for(int y = 0; y < 4; y++) {
            str = "";
            for(int x = 0; x < 4; x++) {
              if(r3.contains(x, y) == true)
                str = str + " #";
              else
                str = str + " -";
            }
            System.out.println(str);
          }
        }
      }

        Attachments

          Activity

            People

            • Assignee:
              flar Jim Graham
              Reporter:
              chialin Chianphon Lin (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: