문제

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?

도움이 되었습니까?

해결책

The easiest would be to create a new WB with the dimension of the final result, then use the Blit() method to copy the region of the source to your new destination bitmap's region.

Nice ASCII art job btw. :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top