File tree Expand file tree Collapse file tree 1 file changed +3
-13
lines changed
src/ImageSharp/Processing/Processors/Drawing Expand file tree Collapse file tree 1 file changed +3
-13
lines changed Original file line number Diff line number Diff line change @@ -96,19 +96,9 @@ protected override void OnFrameApply(ImageFrame<TPixelBg> source)
96
96
top = 0 ;
97
97
}
98
98
99
- if ( left > source . Width - foregroundRectangle . Width )
100
- {
101
- // will overhange, lets trim it down
102
- int diff = ( left + foregroundRectangle . Width ) - source . Width ;
103
- foregroundRectangle . Width -= diff ;
104
- }
105
-
106
- if ( top > source . Height - foregroundRectangle . Height )
107
- {
108
- // will overhange, lets trim it down
109
- int diff = ( top + foregroundRectangle . Height ) - source . Height ;
110
- foregroundRectangle . Height -= diff ;
111
- }
99
+ // clamp the height/width to the availible space left to prevent overflowing
100
+ foregroundRectangle . Width = Math . Min ( source . Width - left , foregroundRectangle . Width ) ;
101
+ foregroundRectangle . Height = Math . Min ( source . Height - top , foregroundRectangle . Height ) ;
112
102
113
103
int width = foregroundRectangle . Width ;
114
104
int height = foregroundRectangle . Height ;
You can’t perform that action at this time.
0 commit comments