이 함수로 비트 맵을 자르기를 원하지만 비트 맵이 자르기 영역보다 작을 수 있으므로이 경우 비트 맵을 더 크게 만들려고합니다.비트 맵 자르기 및 필요한 경우 크기 확장
예를 들어 비트 맵이 200x250이고 250x250의 CropBitmap 메서드를 사용하면 메모리 부족 오류가 발생합니다. 누락 된 왼쪽 50 픽셀이 흰색으로 채워지는 250x250의 비트 맵을 반환해야합니다.
어떻게하면됩니까?
public Bitmap CropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight)
{
var rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
if(bitmap.Width < cropWidth || bitmap.Height < cropHeight)
{
// what now?
}
return bitmap.Clone(rect, bitmap.PixelFormat);
}
이렇게하면 크기를 조정할 때 도움이됩니다. http://snippets.dzone.com/posts/show/4336 – ThePower