private void ExtendPartialSpace(int yStart, int yEnd, Space r) { if (!r.Partial) return; int y; if (r.Rect.Top == yStart) { for (y = r.Rect.Bottom; y < yEnd; y++) { if (LineContainsPixels(subtitleArray, y, r.Rect.Left, r.Rect.Right)) break; } r.Resize(0, 0, 0, y - r.Rect.Bottom); } if (r.Rect.Bottom == yEnd) { for (y = r.Rect.Top; y >= yStart; y--) { if (LineContainsPixels(subtitleArray, y, r.Rect.Left, r.Rect.Right)) break; } r.Resize(0, r.Rect.Top - y, 0, 0); } if (r.Rect.Top <= yStart && r.Rect.Bottom >= yEnd - 1) r.Partial = false; }