本文整理汇总了C#中Nikse.SubtitleEdit.Logic.NikseBitmap.SetPixel方法的典型用法代码示例。如果您正苦于以下问题:C# NikseBitmap.SetPixel方法的具体用法?C# NikseBitmap.SetPixel怎么用?C# NikseBitmap.SetPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.NikseBitmap
的用法示例。
在下文中一共展示了NikseBitmap.SetPixel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethodBinOcrSaveLoad
public void TestMethodBinOcrSaveLoad()
{
string tempFileName = Path.GetTempFileName();
var db = new BinaryOcrDb(tempFileName);
var nbmp = new NikseBitmap(2, 2);
nbmp.SetPixel(0, 0, Color.Transparent);
nbmp.SetPixel(1, 0, Color.Transparent);
nbmp.SetPixel(1, 0, Color.Transparent);
nbmp.SetPixel(1, 1, Color.White);
var bob = new BinaryOcrBitmap(nbmp);
bob.Text = "Debug";
db.Add(bob);
nbmp.SetPixel(0, 0, Color.White);
var bob2 = new BinaryOcrBitmap(nbmp);
bob2.X = 2;
bob2.Y = 4;
bob2.Text = "tt";
bob2.Italic = true;
bob2.ExpandCount = 2;
bob2.ExpandedList = new System.Collections.Generic.List<BinaryOcrBitmap>();
bob2.ExpandedList.Add(bob2);
db.Add(bob2);
db.Save();
db = new BinaryOcrDb(tempFileName, true);
Assert.IsTrue(db.CompareImages.Count == 1);
Assert.IsTrue(db.CompareImagesExpanded.Count == 1);
Assert.IsTrue(bob.Width == db.CompareImages[0].Width);
Assert.IsTrue(bob.Height == db.CompareImages[0].Height);
Assert.IsTrue(bob.NumberOfColoredPixels == db.CompareImages[0].NumberOfColoredPixels);
Assert.IsTrue(bob.Hash == db.CompareImages[0].Hash);
Assert.IsTrue(bob.Italic == db.CompareImages[0].Italic);
Assert.IsTrue(bob.ExpandCount == db.CompareImages[0].ExpandCount);
Assert.IsTrue(bob.Text == db.CompareImages[0].Text);
Assert.IsTrue(bob2.Width == db.CompareImagesExpanded[0].Width);
Assert.IsTrue(bob2.Height == db.CompareImagesExpanded[0].Height);
Assert.IsTrue(bob2.NumberOfColoredPixels == db.CompareImagesExpanded[0].NumberOfColoredPixels);
Assert.IsTrue(bob2.Hash == db.CompareImagesExpanded[0].Hash);
Assert.IsTrue(bob2.Italic == db.CompareImagesExpanded[0].Italic);
Assert.IsTrue(bob2.ExpandCount == db.CompareImagesExpanded[0].ExpandCount);
Assert.IsTrue(bob2.Text == db.CompareImagesExpanded[0].Text);
Assert.IsTrue(bob2.X == db.CompareImagesExpanded[0].X);
Assert.IsTrue(bob2.Y == db.CompareImagesExpanded[0].Y);
try
{
File.Delete(tempFileName);
}
catch
{
}
}
示例2: RemoveBlackBarRight
private static void RemoveBlackBarRight(NikseBitmap bmp)
{
int xRemoveBlackBar = bmp.Width - 1;
for (int yRemoveBlackBar = 0; yRemoveBlackBar < bmp.Height; yRemoveBlackBar++)
{
byte[] c = bmp.GetPixelColors(xRemoveBlackBar, yRemoveBlackBar);
if (c[0] == 0 || IsColorClose(c[0], c[1], c[2], c[3], Color.Black, 280))
{
if (bmp.GetAlpha(xRemoveBlackBar - 1, yRemoveBlackBar) == 0)
bmp.SetPixel(xRemoveBlackBar, yRemoveBlackBar, Color.Transparent);
}
}
}
示例3: GetExpandedSelectionNew
internal static ImageSplitterItem GetExpandedSelectionNew(NikseBitmap bitmap, List<ImageSplitterItem> expandSelectionList)
{
int minimumX = expandSelectionList[0].X;
int maximumX = expandSelectionList[expandSelectionList.Count - 1].X + expandSelectionList[expandSelectionList.Count - 1].NikseBitmap.Width;
int minimumY = expandSelectionList[0].Y;
int maximumY = expandSelectionList[0].Y + expandSelectionList[0].NikseBitmap.Height;
var nbmp = new NikseBitmap(bitmap.Width, bitmap.Height);
foreach (ImageSplitterItem item in expandSelectionList)
{
for (int y = 0; y < item.NikseBitmap.Height; y++)
{
for (int x = 0; x < item.NikseBitmap.Width; x++)
{
int a = item.NikseBitmap.GetAlpha(x, y);
if (a > 100)
nbmp.SetPixel(item.X + x, item.Y + y, Color.White);
}
}
if (item.Y < minimumY)
minimumY = item.Y;
if (item.Y + item.NikseBitmap.Height > maximumY)
maximumY = item.Y + item.NikseBitmap.Height;
}
nbmp.CropTransparentSidesAndBottom(0, true);
int topCropping;
nbmp = NikseBitmapImageSplitter.CropTopAndBottom(nbmp, out topCropping);
return new ImageSplitterItem(minimumX, minimumY, nbmp);
}
示例4: ToOldBitmap
public Bitmap ToOldBitmap()
{
NikseBitmap nbmp = new NikseBitmap(Width, Height);
for (int y = 0; y < Height; y++)
{
for (int x = 0; x < Width; x++)
{
nbmp.SetPixel(x, y, this.GetPixel(x, y));
}
}
return nbmp.GetBitmap();
}
示例5: RemoveBlackBarRight
private static void RemoveBlackBarRight(NikseBitmap bmp)
{
int xRemoveBlackBar = bmp.Width-1;
for (int yRemoveBlackBar = 0; yRemoveBlackBar < bmp.Height; yRemoveBlackBar++)
{
Color c = bmp.GetPixel(xRemoveBlackBar, yRemoveBlackBar);
if (c.A == 0 || IsColorClose(c, Color.Black, 280))
{
if (bmp.GetPixel(xRemoveBlackBar - 1, yRemoveBlackBar).A == 0)
bmp.SetPixel(xRemoveBlackBar, yRemoveBlackBar, Color.Transparent);
}
}
}
示例6: RemoveBlackBarRight
private static void RemoveBlackBarRight(NikseBitmap bmp)
{
int xRemoveBlackBar = bmp.Width - 1;
for (int yRemoveBlackBar = 0; yRemoveBlackBar < bmp.Height; yRemoveBlackBar++)
{
byte[] colors = bmp.GetPixelColors(xRemoveBlackBar, yRemoveBlackBar);
if (colors[0] != 0 && !IsColorClose(colors[0], colors[1], colors[2], colors[3], Color.Black, 280))
{
continue;
}
if (bmp.GetAlpha(xRemoveBlackBar - 1, yRemoveBlackBar) == 0)
{
bmp.SetPixel(xRemoveBlackBar, yRemoveBlackBar, Color.Transparent);
}
}
}