Trying to fix transparent for "Ocr window" regarding transport streams

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2377 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2014-01-14 14:55:30 +00:00
parent 4663366bf9
commit 8092da1b7f
2 changed files with 20 additions and 0 deletions

View File

@ -1269,6 +1269,8 @@ namespace Nikse.SubtitleEdit.Forms
nDvbBmp.CropTransparentSidesAndBottom(2, true);
if (checkBoxTransportStreamGetColorAndSplit.Checked)
_dvbSubColor = nDvbBmp.GetBrightestColor();
if (checkBoxAutoTransparentBackground.Checked)
nDvbBmp.MakeBackgroundTransparent(140); //TODO: Put in UI or settings
if (checkBoxTransportStreamGrayscale.Checked)
nDvbBmp.GrayScale();
dvbBmp.Dispose();

View File

@ -972,5 +972,23 @@ namespace Nikse.SubtitleEdit.Logic
}
}
/// <summary>
/// Make pixels with some transparency completely transparent
/// </summary>
/// <param name="minAlpha">Min alpha value, 0=transparent, 255=fully visible</param>
internal void MakeBackgroundTransparent(int minAlpha)
{
byte[] buffer = new byte[4];
buffer[0] = 0; // B
buffer[1] = 0; // G
buffer[2] = 0; // R
buffer[3] = 0; // A
for (int i = 0; i < _bitmapData.Length; i += 4)
{
if (_bitmapData[i + 3] < minAlpha)
Buffer.BlockCopy(buffer, 0, _bitmapData, i, 4);
}
}
}
}