private Image ColorToBinary(Image img) { Bitmap bmp = new Bitmap(img); Bitmap32 bmp32 = new Bitmap32(bmp); bmp32.LockBitmap(); //bmp32.ToBlackWhite(); int of = bmp32.Offset(); for (int y = 0; y < img.Height; y++) { for (int x = 0; x < img.Width; x++) { bmp32.DrawOutLine(x, y, of); } } bmp32.UnlockBitmap(); //float[][] TempMatrix = { // new float[] {.3f, .3f, .3f, 0, 0}, // new float[] {.59f, .59f, .59f, 0, 0}, // new float[] {.11f, .11f, .11f, 0, 0}, // new float[] {0, 0, 0, 1, 0}, // new float[] {0, 0, 0, 0, 1} //}; //ColorMatrix cmatrix = new ColorMatrix(TempMatrix); //Graphics gp = Graphics.FromImage(img); //ImageAttributes imgAttri = new ImageAttributes(); //imgAttri.SetColorMatrix(cmatrix); //gp.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imgAttri); return(bmp); }
private Image FrameDraw(Image img) { int max = img.Height; int min = img.Height / 8; Graphics gp = Graphics.FromImage(img); Bitmap bmp = new Bitmap(img); System.Drawing.Imaging.PixelFormat Format = img.PixelFormat; for (int i = max; i >= min; i = i / 2) { for (int x = 0; x < img.Width; x += i) { for (int y = 0; y < max; y += i) { Rectangle rect = new Rectangle(0, 0, i, i); Bitmap clone = bmp.Clone(rect, Format); Bitmap32 bmp32 = new Bitmap32(clone); bmp32.LockBitmap(); bmp32.Robert(r, g, b); bmp32.UnlockBitmap(); } } } return(img); }
public void cutChar(Bitmap img) { Graphics gp = Graphics.FromImage(img); Bitmap32 bmp32 = new Bitmap32(img); System.Drawing.Imaging.PixelFormat format = new System.Drawing.Imaging.PixelFormat(); Point top, left, bot, right, prect; bmp32.LockBitmap(); top = bmp32.TopPoint(); left = bmp32.LeftPoint(); bot = bmp32.BotPoint(); right = bmp32.RightPoint(); //bmp32.Vector(); int of = bmp32.Offset(); for (int y = 0; y < img.Height; y++) { for (int x = 0; x < img.Width; x++) { bmp32.DrawOutLine(x, y, of); } } bmp32.UnlockBitmap(); prect = new Point(left.X, top.Y); Rectangle rect = new Rectangle(prect, new Size(right.X - left.X, bot.Y - top.Y)); Bitmap clone = img.Clone(rect, format); gp.DrawRectangle(new Pen(Color.Green), rect); picFitter.Image = clone; }
private void btnSelect_Click(object sender, EventArgs e) { Bitmap bmp = new Bitmap(28, 28); Bitmap32 bmp32 = new Bitmap32(bmp); if (int.Parse(txtNumChar.Text) < CharList.Count) { string[] CharLoad = CharList[int.Parse(txtNumChar.Text)].Split(','); bmp32.LockBitmap(); int c = 0; List <int> il = new List <int>(); for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < bmp.Width; x++) { c = int.Parse(CharLoad[bmp.Width * y + x]); bmp32.SetPixel(x, y, Color.FromArgb(255, c, c, c)); } } bmp32.UnlockBitmap(); cutChar(bmp); bmp.SetResolution(168, 168); Bitmap bmpnew = new Bitmap(bmp, new Size(168, 168)); picHandWritten.Image = bmpnew; } }
private Image BlueFilter(Image img) { Bitmap bmp = new Bitmap(img); Bitmap32 bmp32 = new Bitmap32(bmp); bmp32.LockBitmap(); bmp32.GetBlue(o); bmp32.UnlockBitmap(); return(bmp); }
private Bitmap ToFloySteinberg(Image img) { Bitmap bmp = new Bitmap(img); Bitmap32 bmp32 = new Bitmap32(bmp); bmp32.LockBitmap(); bmp32.FloydSteinberg(o); bmp32.UnlockBitmap(); return(bmp); }
private Image ColorToGrayscale(Image img) { Bitmap bmp = new Bitmap(img); Bitmap32 bmp32 = new Bitmap32(bmp); bmp32.LockBitmap(); bmp32.ToGrayScale(o); bmp32.UnlockBitmap(); return(bmp); }
private void ToHexArray(Image img) { Bitmap bmp = new Bitmap(img, new Size(128, 64)); bmp.SetResolution(128, 64); Bitmap32 bmp32 = new Bitmap32(bmp); bmp32.LockBitmap(); output = bmp32.ToHex(); bmp32.UnlockBitmap(); try { bmp.Save("/test.bmp"); } catch { } }