当前位置: 首页>>代码示例>>C#>>正文


C# NikseBitmap.MakeTwoColor方法代码示例

本文整理汇总了C#中Nikse.SubtitleEdit.Logic.NikseBitmap.MakeTwoColor方法的典型用法代码示例。如果您正苦于以下问题:C# NikseBitmap.MakeTwoColor方法的具体用法?C# NikseBitmap.MakeTwoColor怎么用?C# NikseBitmap.MakeTwoColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nikse.SubtitleEdit.Logic.NikseBitmap的用法示例。


在下文中一共展示了NikseBitmap.MakeTwoColor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TrainLetter

        private void TrainLetter(ref int numberOfCharactersLeaned, ref int numberOfCharactersSkipped, NOcrDb nOcrD, List<string> charactersLearned, string s, bool bold)
        {
            Bitmap bmp = GenerateImageFromTextWithStyle(s, bold);
            var nbmp = new NikseBitmap(bmp);
            nbmp.MakeTwoColor(210, 280);
            var list = NikseBitmapImageSplitter.SplitBitmapToLettersNew(nbmp, 10, false, false, 25);
            if (list.Count == 1)
            {
                NOcrChar match = nOcrD.GetMatch(list[0].NikseBitmap);
                if (match == null)
                {

                    pictureBox1.Image = list[0].NikseBitmap.GetBitmap();
                    this.Refresh();
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(100);

                    NOcrChar nOcrChar = new NOcrChar(s);
                    nOcrChar.Width = list[0].NikseBitmap.Width;
                    nOcrChar.Height = list[0].NikseBitmap.Height;
                    VobSubOcrNOcrCharacter.GenerateLineSegments((int)numericUpDownSegmentsPerCharacter.Value, checkBoxVeryAccurate.Checked, nOcrChar, list[0].NikseBitmap);
                    nOcrD.Add(nOcrChar);

                    charactersLearned.Add(s);
                    numberOfCharactersLeaned++;
                    labelInfo.Text = string.Format("Now training font '{1}', total characters leaned is {0}, {2} skipped", numberOfCharactersLeaned, _subtitleFontName, numberOfCharactersSkipped);
                    bmp.Dispose();
                }
                else
                {
                    numberOfCharactersSkipped++;
                }
            }
        }
开发者ID:nguansak,项目名称:subtitleedit,代码行数:34,代码来源:VobSubNOcrTrain.cs

示例2: 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();
        }
开发者ID:Tarhan,项目名称:subtitleedit,代码行数:101,代码来源:VobSubOcr.cs


注:本文中的Nikse.SubtitleEdit.Logic.NikseBitmap.MakeTwoColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。