This code will crop the image based on all white and transparent pixels from around the image public static Bitmap CropWhiteSpace(Bitmap bmp) { int w = bmp.Width; int h = bmp.Height; int white = 0xffffff; Func< int , bool > allWhiteRow = r => { for ( int i = 0; i < w; ++i) if ((bmp.GetPixel(i, r).ToArgb() & white) != white) return false ; return true ; }; Func< int , bool > allWhiteColumn = c => { for ( int i = 0; i < h; ++i) if ((bmp.GetPixel(c, i).ToArgb() & white) != white) return false ; return true ; }; int topmost = 0; for ( int row = 0; row < h; ++row) { if (!allWhiteRow(row)) break ; topmost = row; } int bottommost = 0; for ( int row = h - 1; row >= 0; --row) { if (!allWhiteRow(row)) break ; bottommost = row; } int leftmost = 0, rightmost = 0; for ( int col = 0; col < w; ++col) { if
That was some great resource that proved beneficial to me to understand some functional programming aspects. At first it looks hard to deal with but later on it was quite simple to get into it.
ReplyDeleteYou might also like this: http://www.itdevspace.com/2011/05/c-functional-programming.html Lots of examples how to use build in linq methods and how to write your own.
ReplyDeleteIt's very effective and helpful to learn about the basic concept of functional programming. For any novice learner, it will be very useful to various aspects of functional programming languages. Through such kinds of programming functions, we have developed a restaurant management software namely Bhojon. Please check out this link to learn more details: https://www.bdtask.com/restaurant-management-system.php
ReplyDelete