リビジョン | 7ebaf7dd76378b9e0866ae6a9b583200b28ac648 (tree) |
---|---|
日時 | 2017-05-12 01:31:01 |
作者 | Kazuhiro Fujieda <fujieda@user...> |
コミッター | Kazuhiro Fujieda |
Fix captured images can have a blank on either side
@@ -399,40 +399,20 @@ namespace BurageSnap | ||
399 | 399 | VerticalRight |
400 | 400 | } |
401 | 401 | |
402 | + // For drop pictures in KanColle with a white region on the top side | |
402 | 403 | public void RoundUpRectangle(byte[,] map, ref Rectangle rect) |
403 | 404 | { |
404 | - var r = rect.Height % 10; | |
405 | - if (r != 0) | |
406 | - { | |
407 | - var top = 0; | |
408 | - var bottom = 0; | |
409 | - for (var x = rect.X; x < rect.Right; x++) | |
410 | - { | |
411 | - if (map[rect.Top - 1, x] == 1) | |
412 | - top++; | |
413 | - if (map[rect.Bottom, x] == 1) | |
414 | - bottom++; | |
415 | - } | |
416 | - rect.Height += 10 - r; | |
417 | - if (top <= bottom) // expand unbiguous edge | |
418 | - rect.Y -= 10 - r; | |
419 | - } | |
420 | - r = rect.Width % 10; | |
421 | - if (r != 0) | |
405 | + if (rect.Width % 10 != 0) | |
406 | + return; | |
407 | + var top = 0; | |
408 | + for (var x = rect.X; x < rect.Right; x++) | |
422 | 409 | { |
423 | - var left = 0; | |
424 | - var right = 0; | |
425 | - for (var y = rect.Y; y < rect.Bottom; y++) | |
426 | - { | |
427 | - if (map[y, rect.Left - 1] == 1) | |
428 | - left++; | |
429 | - if (map[y, rect.Right] == 1) | |
430 | - right++; | |
431 | - } | |
432 | - rect.Width += 10 - r; | |
433 | - if (right <= left) // expand unbiguous edge | |
434 | - rect.X -= 10 - r; | |
410 | + if (map[rect.Top - 1, x] == 1) | |
411 | + top++; | |
435 | 412 | } |
413 | + var r = rect.Height % 10; | |
414 | + if (top > rect.Width / 2 && r != 0) | |
415 | + rect.Height += 10 - r; | |
436 | 416 | } |
437 | 417 | } |
438 | 418 | } |
\ No newline at end of file |