@@ -43,41 +43,65 @@ private static Bitmap UpperLeftCorner
4343 {
4444 get
4545 {
46- var imageData = ReadResourceFile ( "ScreenGrid.Models.Resources.UpperLeftCorner.png" ) ;
47- using ( var ms = new System . IO . MemoryStream ( imageData ) )
48- {
49- return new Bitmap ( ms ) ;
50- }
46+ return ReadPngResouse ( "ScreenGrid.Models.Resources.UpperLeftCorner.png" ) ;
5147 }
5248 }
5349
5450 private static Bitmap LowerRightCorner
5551 {
5652 get
5753 {
58- var imageData = ReadResourceFile ( "ScreenGrid.Models.Resources.LowerRightCorner.png" ) ;
59- using ( var ms = new System . IO . MemoryStream ( imageData ) )
60- {
61- return new Bitmap ( ms ) ;
62- }
54+ return ReadPngResouse ( "ScreenGrid.Models.Resources.LowerRightCorner.png" ) ;
55+ }
56+ }
57+
58+ private static Bitmap UpperLeftCorner2
59+ {
60+ get
61+ {
62+ return ReadPngResouse ( "ScreenGrid.Models.Resources.UpperLeftCorner2.png" ) ;
63+ }
64+ }
65+
66+ private static Bitmap LowerRightCorner2
67+ {
68+ get
69+ {
70+ return ReadPngResouse ( "ScreenGrid.Models.Resources.LowerRightCorner2.png" ) ;
71+ }
72+ }
73+
74+ private static Bitmap ReadPngResouse ( string resourceName )
75+ {
76+ var imageData = ReadResourceFile ( resourceName ) ;
77+ using ( var ms = new System . IO . MemoryStream ( imageData ) )
78+ {
79+ return new Bitmap ( ms ) ;
6380 }
6481 }
6582
6683 private static Point TopLeftCorner ( FlatImage image )
6784 {
68- var topLeftCornerFragment = new FlatImage ( OctaneRenderWindow . UpperLeftCorner ) ;
85+ var topLeftCornerFragments = new [ ]
86+ {
87+ new FlatImage ( OctaneRenderWindow . UpperLeftCorner ) ,
88+ new FlatImage ( OctaneRenderWindow . UpperLeftCorner2 ) ,
89+ } ;
6990
7091 var topLeftCornerX = 0 ;
7192 var topLeftCornerY = 0 ;
72- for ( var x = 0 ; x < image . Width - topLeftCornerFragment . Width ; x ++ )
93+ foreach ( var topLeftCornerFragment in topLeftCornerFragments )
7394 {
74- for ( var y = 0 ; y < image . Height - topLeftCornerFragment . Height ; y ++ )
95+ for ( var x = 0 ; x < image . Width - topLeftCornerFragment . Width ; x ++ )
7596 {
76- if ( image . CompareWithFragmentWithTolerance ( topLeftCornerFragment , x , y ) )
97+ for ( var y = 0 ; y < image . Height - topLeftCornerFragment . Height ; y ++ )
7798 {
78- topLeftCornerX = x + topLeftCornerFragment . Width - 1 ;
79- topLeftCornerY = y + topLeftCornerFragment . Height - 1 ;
80- return new Point ( topLeftCornerX , topLeftCornerY ) ;
99+ if ( image . CompareWithFragmentWithTolerance ( topLeftCornerFragment , x , y ) )
100+ {
101+ topLeftCornerX = x + topLeftCornerFragment . Width - 1 ;
102+ topLeftCornerY = y + topLeftCornerFragment . Height - 1 ;
103+ return new Point ( topLeftCornerX , topLeftCornerY ) ;
104+ }
81105 }
82106 }
83107 }
@@ -87,19 +111,27 @@ private static Point TopLeftCorner(FlatImage image)
87111
88112 private static Point BottomRightCorner ( FlatImage image )
89113 {
90- var bottomRightCornerFragment = new FlatImage ( OctaneRenderWindow . LowerRightCorner ) ;
114+ var bottomRightCornerFragments = new [ ]
115+ {
116+ new FlatImage ( OctaneRenderWindow . LowerRightCorner ) ,
117+ new FlatImage ( OctaneRenderWindow . LowerRightCorner2 ) ,
118+ } ;
91119
92120 var bottomRightCornerX = 0 ;
93121 var bottomRightCornerY = 0 ;
94- for ( var x = 0 ; x < image . Width - bottomRightCornerFragment . Width ; x ++ )
122+ foreach ( var bottomRightCornerFragment in bottomRightCornerFragments )
95123 {
96- for ( var y = 0 ; y < image . Height - bottomRightCornerFragment . Height ; y ++ )
124+ //for (var x = 0; x < image.Width - bottomRightCornerFragment.Width; x++)
125+ for ( var x = image . Width - bottomRightCornerFragment . Width - 1 ; x > 0 ; x -- )
97126 {
98- if ( image . CompareWithFragmentWithTolerance ( bottomRightCornerFragment , x , y ) )
127+ for ( var y = 0 ; y < image . Height - bottomRightCornerFragment . Height ; y ++ )
99128 {
100- bottomRightCornerX = x ;
101- bottomRightCornerY = y ;
102- return new Point ( bottomRightCornerX , bottomRightCornerY ) ;
129+ if ( image . CompareWithFragmentWithTolerance ( bottomRightCornerFragment , x , y ) )
130+ {
131+ bottomRightCornerX = x ;
132+ bottomRightCornerY = y ;
133+ return new Point ( bottomRightCornerX , bottomRightCornerY ) ;
134+ }
103135 }
104136 }
105137 }
@@ -116,8 +148,6 @@ private static Point BottomRightCorner(FlatImage image)
116148 /// <returns></returns>
117149 private static Point TopLeftImage ( FlatImage image , Point topLeftCorner , Point bottomRightCorner )
118150 {
119- var topLeftCornerFragment = new FlatImage ( OctaneRenderWindow . UpperLeftCorner ) ;
120-
121151 var topLeftImageX = 0 ;
122152 var topLeftImageY = 0 ;
123153
@@ -154,8 +184,6 @@ private static Point TopLeftImage(FlatImage image, Point topLeftCorner, Point bo
154184 /// <returns></returns>
155185 private static Point BottomRightImage ( FlatImage image , Point topLeftCorner , Point bottomRightCorner )
156186 {
157- var bottomRightCornerFragment = new FlatImage ( OctaneRenderWindow . LowerRightCorner ) ;
158-
159187 var areaColor2 = image . pixels [ ( int ) bottomRightCorner . X , ( int ) bottomRightCorner . Y ] ;
160188
161189 for ( var y = ( int ) bottomRightCorner . Y - 1 ; y > ( int ) topLeftCorner . Y ; y -- )
0 commit comments