mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
More crop for VobSub
This commit is contained in:
parent
429bdb3360
commit
3ad9da7d8d
@ -914,6 +914,20 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return Height - y;
|
||||
}
|
||||
|
||||
public int CalcBottomTransparent()
|
||||
{
|
||||
var y = Height - 1;
|
||||
for (; y > 0; y--)
|
||||
{
|
||||
if (!IsHorizontalLineTransparent(y))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Height - y;
|
||||
}
|
||||
|
||||
public int CalcLeftCropping(Color color)
|
||||
{
|
||||
var x = 0;
|
||||
@ -968,6 +982,19 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsHorizontalLineTransparent(int y)
|
||||
{
|
||||
for (var x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetAlpha(x, y) > 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Fill(Color color)
|
||||
{
|
||||
var buffer = new byte[4];
|
||||
|
@ -2330,9 +2330,11 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
var nbmp = new NikseBitmap(bmp);
|
||||
var topCropped = nbmp.CropTopTransparent(0);
|
||||
top += topCropped;
|
||||
var bottomCropped = nbmp.CalcBottomTransparent();
|
||||
width = bmp.Width;
|
||||
height = bmp.Height;
|
||||
height -= topCropped;
|
||||
height -= bottomCropped;
|
||||
bmp.Dispose();
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user