I need to crop an image specifying coordinates that may exceed the image's bounds. If the coordinates are off, appropriate padding is applied.
Normally:
+===============+
| Source Bitmap |
| +-------+ |
| + Crop + |
| +-------+ |
| |
+===============+
...which works perfectly well with WriteableBitmapEx's Crop()
extension. But in my case:
+-----------+
+ Crop +
+ +
+ +===============+
+ | Source Bitmap |
+ | |
+ +===============+
+ +
+-----------+
In this case, the bounds exceed the top, left, and bottom. The resulting bitmap need to be:
+-----------+
+ +
+ +
+ +=========+
+ | +
+ | +
+ +=========+
+ +
+-----------+
What's the best (and fastest) way to accomplish this?