private static bool IsCursiveVerticalLineTransparent(NikseBitmap bmp, int size, int y, int x, List <Point> cursivePoints) { bool cursiveOk = true; int newY = y; int newX = x; while (cursiveOk && newY < bmp.Height - 1) { Color c0 = bmp.GetPixel(newX, newY); if (c0.A == 0 || IsColorClose(c0, Color.Black, 280)) { newY++; } else { byte[] c1 = bmp.GetPixelColors(newX - 1, newY - 1); byte[] c2 = bmp.GetPixelColors(newX - 1, newY); if ((c1[0] == 0 || IsColorClose(c1[0], c1[1], c1[2], c1[3], Color.Black, 280)) && // still dark color... (c2[0] == 0 || IsColorClose(c2[0], c2[1], c2[2], c2[3], Color.Black, 280))) { cursivePoints.Add(new Point(newX, newY)); if (newX > 1) { newX--; } else { cursiveOk = false; } newY++; } else { cursiveOk = false; } } if (newX < x - size) { cursiveOk = false; } } return(cursiveOk); }
private static bool IsVerticalLineTransparent(NikseBitmap bmp, out int y, int x) { for (y = 0; y < bmp.Height - 1; y++) { var argb = bmp.GetPixelColors(x, y); if (argb[0] >= 10 && !IsColorClose(argb[0], argb[1], argb[2], argb[3], Color.Black, 280)) { return(false); } } return(true); }
private static bool IsVerticalLineTransparent(NikseBitmap bmp, ref int y, int x) { for (y = 0; y < bmp.Height - 1; y++) { var argb = bmp.GetPixelColors(x, y); if (argb[0] < 10 || IsColorClose(argb[0], argb[1], argb[2], argb[3], Color.Black, 280)) // still dark color... { } else { return(false); } } return(true); }
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); } } } }
private static bool IsVerticalLineTransparent(NikseBitmap bmp, ref int y, int x) { for (y = 0; y < bmp.Height - 1; y++) { var argb = bmp.GetPixelColors(x, y); if (argb[0] < 10 || IsColorClose(argb[0], argb[1], argb[2], argb[3], Color.Black, 280)) // still dark color... { } else { return false; } } return true; }
private static bool IsCursiveVerticalLineTransparent(NikseBitmap bmp, int size, int y, int x, List<Point> cursivePoints) { bool cursiveOk = true; int newY = y; int newX = x; while (cursiveOk && newY < bmp.Height - 1) { Color c0 = bmp.GetPixel(newX, newY); if (c0.A == 0 || IsColorClose(c0, Color.Black, 280)) { newY++; } else { byte[] c1 = bmp.GetPixelColors(newX - 1, newY - 1); byte[] c2 = bmp.GetPixelColors(newX - 1, newY); if ((c1[0] == 0 || IsColorClose(c1[0], c1[1], c1[2], c1[3], Color.Black, 280)) && // still dark color... (c2[0] == 0 || IsColorClose(c2[0], c2[1], c2[2], c2[3], Color.Black, 280))) { cursivePoints.Add(new Point(newX, newY)); if (newX > 1) newX--; else cursiveOk = false; newY++; } else { cursiveOk = false; } } if (newX < x - size) cursiveOk = false; } return cursiveOk; }
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); } } }
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); } } }