本文整理汇总了C#中Nikse.SubtitleEdit.Logic.NikseBitmap.CropTopTransparent方法的典型用法代码示例。如果您正苦于以下问题:C# NikseBitmap.CropTopTransparent方法的具体用法?C# NikseBitmap.CropTopTransparent怎么用?C# NikseBitmap.CropTopTransparent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.NikseBitmap
的用法示例。
在下文中一共展示了NikseBitmap.CropTopTransparent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
internal void Initialize(Bitmap bitmap, int pixelsIsSpace, bool rightToLeft, NOcrDb nOcrDb, VobSubOcr vobSubOcr)
{
_bitmap = bitmap;
var nbmp = new NikseBitmap(bitmap);
nbmp.ReplaceNonWhiteWithTransparent();
bitmap = nbmp.GetBitmap();
_bitmap2 = bitmap;
_nocrChars = nOcrDb.OcrCharacters;
_matchList = new List<VobSubOcr.CompareMatch>();
_vobSubOcr = vobSubOcr;
int minLineHeight = 6;
_imageList = NikseBitmapImageSplitter.SplitBitmapToLettersNew(nbmp, pixelsIsSpace, rightToLeft, Configuration.Settings.VobSubOcr.TopToBottom, minLineHeight);
// _imageList = NikseBitmapImageSplitter.SplitBitmapToLetters(nbmp, pixelsIsSpace, rightToLeft, Configuration.Settings.VobSubOcr.TopToBottom);
int index = 0;
while (index < _imageList.Count)
{
ImageSplitterItem item = _imageList[index];
if (item.NikseBitmap == null)
{
listBoxInspectItems.Items.Add(item.SpecialCharacter);
_matchList.Add(null);
}
else
{
nbmp = item.NikseBitmap;
nbmp.ReplaceNonWhiteWithTransparent();
item.Y += nbmp.CropTopTransparent(0);
nbmp.CropTransparentSidesAndBottom(0, true);
nbmp.ReplaceTransparentWith(Color.Black);
//get nocr matches
Nikse.SubtitleEdit.Forms.VobSubOcr.CompareMatch match = vobSubOcr.GetNOcrCompareMatchNew(item, nbmp, nOcrDb, false, false);
if (match == null)
{
listBoxInspectItems.Items.Add("?");
_matchList.Add(null);
}
else
{
listBoxInspectItems.Items.Add(match.Text);
_matchList.Add(match);
}
}
index++;
}
}
示例2: listBoxSubtitles_SelectedIndexChanged
private void listBoxSubtitles_SelectedIndexChanged(object sender, EventArgs e)
{
int idx = listBoxSubtitles.SelectedIndex;
if (idx < 0)
return;
int pid = _tsParser.SubtitlePacketIds[listBoxTracks.SelectedIndex];
var list = _tsParser.GetDvbSubtitles(pid);
var dvbBmp = list[idx].GetActiveImage();
var nDvbBmp = new NikseBitmap(dvbBmp);
nDvbBmp.CropTopTransparent(2);
nDvbBmp.CropTransparentSidesAndBottom(2, true);
dvbBmp.Dispose();
var oldImage = pictureBox1.Image;
pictureBox1.Image = nDvbBmp.GetBitmap();
if (oldImage != null)
oldImage.Dispose();
}
示例3: GetSubtitleBitmap
//.........这里部分代码省略.........
part.MakeTransparent();
using (var g = Graphics.FromImage(merged))
g.DrawImage(part, 0, y);
y += part.Height + 7;
part.Dispose();
}
b = merged;
}
else if (bitmaps.Count == 1)
{
b = bitmaps[0];
}
if (b != null)
{
if (_isSon && checkBoxCustomFourColors.Checked)
{
GetCustomColors(out background, out pattern, out emphasis1, out emphasis2);
FastBitmap fbmp = new FastBitmap(b);
fbmp.LockImage();
for (int x = 0; x < fbmp.Width; x++)
{
for (int y = 0; y < fbmp.Height; y++)
{
Color c = fbmp.GetPixel(x, y);
if (c.R == Color.Red.R && c.G == Color.Red.G && c.B == Color.Red.B) // normally anti-alias
fbmp.SetPixel(x, y, emphasis2);
else if (c.R == Color.Blue.R && c.G == Color.Blue.G && c.B == Color.Blue.B) // normally text?
fbmp.SetPixel(x, y, pattern);
else if (c.R == Color.White.R && c.G == Color.White.G && c.B == Color.White.B) // normally background
fbmp.SetPixel(x, y, background);
else if (c.R == Color.Black.R && c.G == Color.Black.G && c.B == Color.Black.B) // outline/border
fbmp.SetPixel(x, y, emphasis1);
else
fbmp.SetPixel(x, y, c);
}
}
fbmp.UnlockImage();
}
if (checkBoxAutoTransparentBackground.Checked)
b.MakeTransparent();
returnBmp = b;
}
}
}
else if (_xSubList != null)
{
if (checkBoxCustomFourColors.Checked)
{
GetCustomColors(out background, out pattern, out emphasis1, out emphasis2);
returnBmp = _xSubList[index].GetImage(background, pattern, emphasis1, emphasis2);
}
else
{
returnBmp = _xSubList[index].GetImage();
}
}
else if (_dvbSubtitles != null)
{
var dvbBmp = _dvbSubtitles[index].GetActiveImage();
var nDvbBmp = new NikseBitmap(dvbBmp);
nDvbBmp.CropTopTransparent(2);
nDvbBmp.CropTransparentSidesAndBottom(2, true);
if (checkBoxTransportStreamGetColorAndSplit.Checked)
_dvbSubColor = nDvbBmp.GetBrightestColor();
if (checkBoxAutoTransparentBackground.Checked)
nDvbBmp.MakeBackgroundTransparent((int)numericUpDownAutoTransparentAlphaMax.Value);
if (checkBoxTransportStreamGrayscale.Checked)
nDvbBmp.GrayScale();
dvbBmp.Dispose();
returnBmp = nDvbBmp.GetBitmap();
}
else if (_bluRaySubtitlesOriginal != null)
{
returnBmp = _bluRaySubtitles[index].GetBitmap();
}
else if (checkBoxCustomFourColors.Checked)
{
GetCustomColors(out background, out pattern, out emphasis1, out emphasis2);
returnBmp = _vobSubMergedPackist[index].SubPicture.GetBitmap(null, background, pattern, emphasis1, emphasis2, true);
if (checkBoxAutoTransparentBackground.Checked)
returnBmp.MakeTransparent();
}
else
{
returnBmp = _vobSubMergedPackist[index].SubPicture.GetBitmap(_palette, Color.Transparent, Color.Black, Color.White, Color.Black, false);
if (checkBoxAutoTransparentBackground.Checked)
returnBmp.MakeTransparent();
}
if (_binaryOcrDb == null && _nOcrDb == null)
return returnBmp;
var n = new NikseBitmap(returnBmp);
n.MakeTwoColor(210, 280);
returnBmp.Dispose();
return n.GetBitmap();
}