C # Monographs of various graphs (transferred from C # learning note 2) (unfinished)

xiaoxiao2021-03-06  40

//Image Processing---------------------------------------------- ----------------------------------------

Using system.drawing; using system.drawing.image;

Namespace zft {public class bitmapfilter {public static bool {public static boore, INT G, INT B) {if (r == 0) r = 1; if (g == 0) g = 1; if (b == 0) b = 1; BitmapData bmData = image.LockBits (new Rectangle (0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); unsafe {int stride = bmData.Stride; System .Intptr scan0 = bmdata.scan0; Byte * p = (byte *) (void *) scan0; int noffset = stride - image.width * 3; int nwidth = image.width; int = image.height; int Red, Green, Blue;

INT W0 = (int); int h0 = (int); int R0, T1, T2, KR = R, KG = G, KB = B; Double Z, Z0;

INT K1R = R, K1G = G, K1B = B, K2R = R, K2G = G, K2B = B, K3R = R, K3G = G, K3B = B, K4R = R, K4G = G, K4B = B; IF (W0> H0) R0 = W0; ELSE R0 = H0; Z0 = Math.SQRT (W0 * W0 H0 * H0); Z0 = Z0 / 1.5;

For (int y = 0; y

{

For (int x = 0; x

{

RED = P [2];

Green = p [1];

Blue = p [0];

T1 = X-W0;

T2 = Y-H0;

IF (T1 <0) T1 = 0-T1; IF (T2 <0) T2 = 0-T2; Z = Math.SQRT (T1 * T1 T2 * T2); if (Z

{

z = z0;

KR = 0;

Kg = 0;

KB = 0;

}

Else

{

Double xx = (z-z0) / z;

Kr = (int) (15 * r * xx * xx);

Kg = (int) (15 * g * xx * xx);

KB = (int) (15 * b * xx * xx);

}

Red = KR;

Green = kg;

Blue = KB;

IF (red> 255) Red = 255; if (red <0) RED = 0; IF (Green> 255) Green = 255; if (Green <0) Green = 0; if (Blue> 255) Blue = 255; IF (blue <0) blue = 0; p [2] = (byte) red; p [1] = (byte) green; p [0] = (byte) blue; p = 3;} p = noffset; }} Image.unlockbits (bmdata); return true;} ///

/// Reversal circle compensation ////

/// Image /// reverse difference coefficient /// circular radius coefficient //////

public static bool ccon (Bitmap image, float con, float k) {BitmapData bmData = image.LockBits (new Rectangle (0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); unsafe {int Stride = bmdata.stride; system.intptr scan0 = bmdata.scan0; byte * p = (byte *) (void *) scan0; int noffset = stride - image.width * 3; int nwidth = image.width; int nHeiGHT = IMAGE.HEIGHT; int Red, Green, Blue;

INT W0 = (INT); int h0 = (int); int R0, T1, T2; Double Z, Z0, Pixel, Contrast; IF (W0> H0) R0 = W0; ELSE R0 = H0; Z0 = Math.sqrt (W0 * W0 H0 * H0); Z0 = Z0 / K;

For (int y = 0; y

{

For (int x = 0; x

{

RED = P [2];

Green = p [1];

Blue = p [0];

T1 = X-W0;

T2 = Y-H0;

IF (T1 <0) T1 = 0-T1; IF (T2 <0) T2 = 0-T2; z = Math.SQRT (T1 * T1 T2 * T2); if (z> z0) {Contrast = (Z -z0) / z * con;

Pixel = red- (127-red) * Contrast; IF (Pixel <0) Pixel = 0; IF (Pixel> 255) Pixel = 255; p [2] = (byte) Pixel;

Pixel = Green- (127-Green) * Contrast; IF (Pixel <0) Pixel = 0; IF (Pixel> 255) Pixel = 255; P [1] = (byte) Pixel; Pixel = Blue- (127-Blue) ) * Contrast; IF (Pixel <0) Pixel = 0; if (Pixel> 255) Pixel = 255; p [0] = (byte) Pixel;} P = 3;} p = noffset;}}} image.unlockbits (BMDATA); Return True;} ///

/// Basic contrast adjustment ///

/// / / /////

Public Static Bool Contrast (Bitmap B, INT NCONTRAST) {IF (NCONTRAST <-100) Return False; if (NCONTRAST> 100) Return False;

Double Pixel = 0, Contrast = (100.0 NCONTRAST) /100.0;

Contrast * = contrast;

INT Red, Green, Blue; // GDI Still Lies To US - The Return Format IS BGR, NOT RGB. Bitmapdata Bmdata = B.Lockbits (New Rectangle (0, 0, B.Width, B.Height), ImageLockMode.Readwrite , Pixelformat.Format24bppRGB);

Int stride = bmdata.stride; system.intptr scan0 = bmdata.scan0; int h = b.height, w = b.width; unsafe {byte * p = (byte *) scan0;

INT Noffset = Stride - B.Width * 3; for (int y = 0; y

{

For (int x = 0; x

{

Blue = p [0];

Green = p [1];

RED = P [2];

Pixel = RED / 255.0;

Pixel - = 0.5;

Pixel * = contrast;

Pixel = 0.5;

Pixel * = 255;

IF (Pixel <0) pixel = 0;

IF (Pixel> 255) Pixel = 255;

P [2] = (byte) Pixel;

Pixel = Green / 255.0; Pixel - = 0.5; Pixel * = Contrast; Pixel = 0.5; pixel * = 255; if (Pixel <0) Pixel = 0; if (Pixel> 255) Pixel = 255; P [1] = (Byte) Pixel; Pixel = Blue / 255.0; Pixel - = 0.5; Pixel * = Contrast; Pixel = 0.5; Pixel * = 255; if (Pixel <0) Pixel = 0; if (Pixel> 255) Pixel = 255; p [0] = (byte) Pixel; p = 3;} p = noffset;}} b.unlockbits (bmdata); returntrue;} public static bool zft (Bitmap B, Out Int "all, Out int rt [] rhow, out int [] ghow, out int [] bhow) {int []; int [= new int = ", int [] gg = new int [256 ]; Int [] bb = new int [256]; int TT = 0; Foreach (INT i in gray) {Gray [i] = 0;} foreach (int I in rr) {rR [i] = 0;} Foreach (INT i] = 0;} foreach (int I in b) {bb [i] = 0;} // GDI STILL LIES TO US - The Return Format IS BGR, NOT RGB. Bitmapdata Bmdata = b.lockbits (New Rectangle) , 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); int stride = bmData.Stride; System.IntPtr Scan0 = bmData.Scan0; unsafe {byte * p = (byte *) (void * ) Scan0; int Noffset = Stride - B.Width * 3; Byte Red, Green, Blue; Int nwidth = B.Width; int nheight = b. HEIGHT; for (int y = 0; y {

For (int x = 0; x

{

Blue = p [0];

Green = p [1];

RED = P [2];

Tt = (byte) (. 299 * red .587 * Green .114 * blue); RR [RED] ; GG [Green] ; BB [Blue] ; Gray [TT] ; P = 3;} p = noffset;}} all = gray; rhow = rr; ghow = gg; bhow = bb; b.unlockbits (bmdata); returntrue;}}} // histogram ---- -------------------------------------------------- -------------------- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; Using system.drawing.imaging; use system.drawing.drawing2d; Namespace ZFT {/// /// Form1 summary description. /// public class form1: system.windows.Forms.form {///// The required designer variable.

/// private system.componentmodel.container components = null; private system.windows.Forms.Button Button1; int [] Gray = new int [256]; int [] rr = new int [256]; int [] gg = New int [256]; int [] bb = new int [256]; public bitmap a = new bitmap (500, 500); public bitmap b = new bitmap (500, 500); Pen Pen1 = new pen (color.black); int FLAG = 0; float count; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Label label1; private System.Windows .Forms.GroupBox groupBox1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label9; private System.Windows .Forms.Label label10; private System.Windows.Forms.Label l_sejie; private System.Windows.Forms.Label l_pinjun; private System.Windows.Forms.Label l_pixel; private System.Windows.Forms.Label label3; priva te System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox3; float [] gl = new float [256]; private System.Windows.Forms.Label l_bfb; private System.Windows.Forms.Label l_how ; private bool aline = false; private System.Windows.Forms.Label lcolor; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label11; private System. Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button undo; private System.Windows.Forms.Button refresh; int xx = -1;

Public Form1 () {// // Windows Form Designer Support for // InitializationComponent (); // // // //////} //// / / / / / / / Resources being used. /// Protected {if (disponents! = Null) {components.dispose ();}} Base.dispose ();} #Region Windows Form Designer Generated Code // /// Designer Supports the required method - Do not modify the // this method using the code editor.

/// private void InitializeComponent () {System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof (Form1)); this.button1 = new System.Windows.Forms.Button (); this.button2 = new System .Windows.Forms.Button (); this.button3 = new system.windows.Forms.Button (); this.button4 = new system.windows.Forms.Button (); this.label1 = new System.Windows.Forms. Label (); this.groupbox1 = new system.windows.forms.groupbox (); this.button5 = new system.windows.Forms.Button (); this.l_pinjun = new system.windows.forms.label (); this .l_pixel = new System.Windows.Forms.Label (); this.textBox1 = new System.Windows.Forms.TextBox (); this.groupBox4 = new System.Windows.Forms.GroupBox (); this.groupBox2 = new System .Windows.forms.groupbox (); this.label11 = new system.windows.forms.label (); this.label6 = new system.windows.forms.label (); this.label5 = new system.windows.forms. Label (); this.lcolor = new system.windows.forms.label (); this.textbox3 = ne W System.Windows.Forms.TextBox (); this.l_how = new system.windows.forms.label (); this.l_bfb = new system.windows.forms.label (); this.label10 = new system.windows. Forms.Label (); this.label9 = new system.windows.forms.label (); this.label8 = new system.windows.forms.label (); this.label7 = new system.windows.forms.label () "This.l_sejie = new system.windows.forms.label (); this.label3 = new system.windows.forms.Label (); this.label2 = new system.windows.forms.label (); this.undo = New system.windows.Forms.Button (); this.refresh = new system.windows.forms.button (); this.groupbox1.suspendlayout ();

THIS.SUSPENDLAYOUT (); // // button1 // this.button1.location = new system.drawing.point (276, 56); this.button1.name = "button1"; this.button1.size = new system. Drawing.size (64, 28); this.Button1.Tabindex = 0; this.button1.text = "grays"; this.button1.textalign = system.drawing.contentAlignment.bottomcenter; this.button1.click = new System.EventHandler (this.button1_click); // // Button2 // this.button2.location = new system.drawing.point (276, 92); this.button2.name = "button2"; this.button2.size = New system.drawing.size (64, 28); this.button2.tabindex = 1; this.button2.text = "red"; this.button2.textalign = system.drawing.contentAlignment.bottomcenter; this.button2.click = New System.EventHandler (this.Button2_Click); /// button3 // this.button3.location = new system.drawing.point (276, 124); this.button3.name = "button3"; this.button3. Size = new system.drawing.size (64, 28); this.button3.tabindex = 2; this.button3.text = "green"; this.button3.TextAlign = System.Drawing.ContentAlignment.BottomCenter; this.button3.Click = new System.EventHandler (this.button3_Click); // // button4 // this.button4.Location = new System.Drawing.Point (276, 156); this.button4.name = "button4"; this.button4.size = new system.drawing.size (64, 28); this.button4.tabindex = 3; this.button4.text = "blue "; This.button4.textalign = system.drawing.contentAlignment.bottomcenter; this.button4.click = new system.eventhandler (this.button4_click);

// // label1 // this.label1.BackColor = System.Drawing.Color.White; this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.label1.Cursor = System.Windows.Forms.Cursors .Cross; this.label1.location = new system.drawing.point (12, 56); this.label1.name = "label1"; this.label1.size = new system.drawing.size (258, 129); this .label1.TabIndex = 4; this.label1.Paint = new System.Windows.Forms.PaintEventHandler (this.label1_Paint); this.label1.MouseUp = new System.Windows.Forms.MouseEventHandler (this.label1_MouseUp); this .label1.MouseMove = new System.Windows.Forms.MouseEventHandler (this.label1_MouseMove); this.label1.MouseDown = new System.Windows.Forms.MouseEventHandler (this.label1_MouseDown); // // groupBox1 // this. Groupbox1.controls.add (this.button5); this.groupBox1.controls.add (this.l_pinjun); this.groupBox1.controls.add (this.l_pixel); this.groupBox1.controls.add (THIS.TEXTBOX1); THIS.GroupBox1.controls.add (this.groupbox4); THIS.GroupBox1.controls.add (this.groupBox2); this.groupBox1.controls.add (this.label11); this.groupBox1.controls.add (this.label6); this.groupbox1.controls.add (this.label5 ); This.groupBox1.controls.add (this.lcolor); this.groupBox1.controls.add (this.textBox3); this.groupbox1.controls.add (this.l_how); this.groupBox1.controls.add (this .l_bfb); this.groupbox1.controls.add (this.label10); this.groupBox1.controls.add (this.label9); this.groupBox1.controls.add (this.label8); this.groupBox1.controls.add (this.label7); this.groupBox1.controls.add (this.l_sejie); this.groupBox1.controls.add (this.label3); this.groupBox1.controls.add (this.label1);

This.GroupBox1.controls.add (this.button2); this.groupBox1.controls.add (this.button3); this.groupBox1.controls.add (this.button1); this.groupbox1.controls.add (this.button4 ); This.groupBox1.controls.add (this.label2); this.groupbox1.font = new system.drawing.font ("Song", 12F); this.groupBox1.Location = new system.drawing.point (8, 4); this.groupbox1.name = "groupbox1"; this.groupbox1.size = new system.drawing.size (352, 340); this.groupBox1.tabindex = 5; this.groupBox1.tabstop = false; this.groupbox1 .Text = "histogram"; this.groupbox1.paint = new system.windows.Forms.PainteventHandler (this.groupbox1_paint); // // button5 // this.button5.location = new system.drawing.point (276 , 224); this.button5.name = "button5"; this.button5.size = new system.drawing.size (64, 24); this.button5.tabindex = 26; this.button5.text = "ok"; This.button5.click = new system.eventhandler (this.button5_click); // // l_pinjun // this.l_pinjun.location = new system.drawing. Point (76, 292); this.l_pinjun.name = "l_pinjun"; this.l_pinjun.size = new system.drawing.size (88, 20); this.l_pinjun.tabINDEX = 8; this.l_pinjun.text = " 0 "; this.l_pinjun.textalign = system.drawing.contentalignment.drawing.ContentAlignment.middleleft; // // l_pixel // this.l_pixel.location = new system.drawing.point (76, 272); this.l_pixel.name =" l_pixel "; This.l_pixel.size = new system.drawing.size (88, 20); this.l_pixel.tabindex = 9; this.l_pixel.text =" 0 "; this.l_pixel.textAlign = system.drawing.contentalignment. Middleleft;

////////////////////////////////Wwndrawing.point (124, 224); this.textbox1.name = "textbox1"; this.textBox1.size = new system.drawing.size (48, 26); this.TextBox1.tabindex = 16; this.TextBox1.text = "0"; // // Groupbox4 // this.groupbox4.location = new system.drawing.point (176, 228); this.groupBox4. Name = "groupbox4"; this.groupbox4.size = new system.drawing.size (44, 8); this.groupbox4.tabindex = 25; this.groupbox4.tabstop = false; // // groupbox2 // this.groupbox2 .Location = new system.drawing.point (176, 32); this.groupbox2.name = "groupbox2"; this.groupbox2.size = new system.drawing.size (40, 8); this.groupbox2.tabindex = 24 "This.groupbox2.tabstop = false; // // label11 // this.label11.borderstyle = system.windows.Forms.Borderstyle.Drawing.Location = new system.drawing.point (220, 28); This.label11.name = "label11"; this.label11.size = new system.drawing.size (52, 23); this.label11.tabi ndex = 23; this.label11.Text = "255"; this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // label6 // this.label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D This.label6.location = new system.drawing.point (124, 28); this.label6.name = "label6"; this.label6.size = new system.drawing.size (48, 23); this.Label6 . TabINDEX = 22; this.label6.text = "0"; this.label6.textalign = system.drawing.contentalignment.middleCenter; // // Label5 // this.label5.location = new system.drawing.point (8 , 224);

THISLABEL5.NAME = "label5"; this.label5.size = new system.drawing.size (116, 23); this.label5.tabindex = 21; this.Label5.Text = "Output color order range:" // // lcolor // this.lcolor.borderstyle = system.windows.Forms.Borderstyle.fixed3d; this.lcolor.location = new system.drawing.point (12, 192); this.lcolor.name = "lcolor" This.lcolor.size = new system.drawing.size (260, 12); this.lcolor.tabindex = 19; this.lcolor.paint = new system.windows.forms.painteventhandler (this.lcolor_paint); // // textBox3 // this.textBox3.Location = new system.drawing.point (224, 224); this.textbox3.name = "textbox3"; this.textBox3.size = new system.drawing.size (48, 26) Im.TextBox3.TabINDEX = 18; this.textBox3.text = "255"; // // l_how // this.l_how.location = new system.drawing.point (212, 292); this.l_how.name = "l_how"; this.l_how.size = new system.drawing.size (120, 20); this.l_how.tabindex = 15; this.l_how.textalign = system.drawing.contentAlignment.middlele ft; // // l_bfb // this.l_bfb.location = new system.drawing.point (208, 312); this.l_bfb.name = "l_bfb"; this.l_bfb.size = new system.drawing.size 124, 20); this.l_bfb.tabindex = 14; this.l_bfb.textalign = system.drawing.contentalignment.middleleft; // // label10 // this.label10.location = new system.drawing.point (144, 312 This.label10.name = "label10"; this.label10.size = new system.drawing.size (68, 20); this.label10.TabINDEX = 13; this.label10.Text = "Percentage:"; " .Label10.Textalign =

System.drawing.content; // // label9 // this.label9.location = new system.drawing.point (16, 28); this.label9.name = "label9"; this.label9.size = new System.drawing.size (84, 23); this.label9.tabindex = 12; this.label9.text = "Color order range:"; // // label8 // this.label8.location = new system.drawing. Point (4, 292); this.label8.name = "label8"; this.label8.size = new system.drawing.size (68, 20); this.label8.tabindex = 11; this.Label8.text = " Average: "; this.label8.textalign = system.drawing.contentAlignment.middleright; // // Label7 // this.label7.location = new system.drawing.point (144, 272); this.label7.name = "label7"; this.label7.size = new system.drawing.size (68, 20); this.label7.tabindex = 10; this.label7.text = "hH.Label7.TextAlign = system. Drawing.content; // // l_sejie // THISL_SEJIE.LOCATION = New System.drawing.Point (212, 272); this.l_sejie.name = "l_sejie"; this.l_seji e.size = new system.drawing.size (120, 20); this.l_sejie.tabindex = 7; this.l_sejie.textalign = system.drawing.contentalignment.middleleft; // // label3 // this.label3.location = new system.drawing.point (152, 292); this.label3.name = "label3"; this.label3.size = new system.drawing.size (60, 20); this.Label3.tabindex = 6; this .Label3.Text = "Quantity:"; this.label3.textalign = system.drawing.contentalignment.middleright; // // Label2 // this.label2.location = new system.drawing.point (16, 272); this .Label2.name = "

Label2 "; this.label2.size = new system.drawing.size (56, 20); this.label2.tabindex = 5; this.label2.text =" pixel: "; this.label2.textalign = system.drawing. ContentAlignment.middleright; /// undo // this.undo.location = new system.drawing.point (368, 16); this.undo.Name = "undo"; this.undo.tabindex = 6; this.undo .Text = "undo"; this.undo.click = new system.eventhandler (this.undo_click); //// refresh // this.refresh.location = new system.drawing.point (368, 48); this .refresh.name = "refresh"; this.refresh.tabindex = 7; this.refresh.text = "refresh"; this.refresh.click = new system.eventhandler (this.refresh_click); // // Form1 / / This.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (450, 350); this.Controls.add (this.refresh); this.controls.add ( This.Controls.add (this.groupBox1); this.formbook.formstyle = system.windows.Forms.FormBorderstyle.fixedToolWindow; this.icon = ((S YSOTEM.DRAWING.ICON) ("$ this.icon")))); this.name = "form1"; this.text = "Color order and histogram"; this.Load = New System.Eventhandler (this.form1_load); this.groupBox1.resumeLayout (false); this.ResumeLayout (false); // may have lack here} #ENDREGION PRIVATE VOID FORM1_LOAD (Object Sender, System.EventArgs E) {this.topmost = true; This.Left = 800; BitmapFilter.zft (A, Out Gray, Out Rr, Out GG, OUT BB); graydo (); this.invalide ();} protected override void onpaint (painteventAntargs e) {base.onpaint (e) ); Graphics g = E.Graphics;

} Private void button1_click (object sender, system.eventargs e) {graydo ();} private void graydo () {this.flag = 1; count = a.width * a.height; gl = new float [256]; for (INT i = 0; i <256; i ) GL [i] = Gray [i] / count * 10000; Pen1 = Pens.black; this.label1.invalidate (); this.lcolor.invalidate ();} private Void Button2_Click (Object Sender, System.EventArgs E) {this.flag = 2; count = a.width * a.height; gl = new float [256]; for (int i = 0; i <256; i ) GL [i] = rr [i] / count * 10000; pen1 = pens.red; this.label1.invalidate (); this.lcolor.invalidate ();} private void button3_click (Object sender, system.eventargs e) {THIS .flag = 3; count = a.width * a.height; gl = new float [256]; for (int i = 0; i <256; i ) GL [i] = GG [i] / count * 10000; Pen1 = Pens.green; this.label1.invalidate (); this.lcolor.invalidate ();} private void button4_click (object sender, system.eventargs e) {this.flag = 4; count = a.width * a. Height; gl = new float [256]; for (int i = 0; i <256; i ) GL [I] = BB [I] / count * 10000; Pen1 = Pens.blue; this.label1.invalide (); this.lcolor.invalidate ();} private void label1_paint (Object Sender, System.Windows. Forms.painteventargs e) {graphics g = e.graphchics; int p; p = a.width * a.height; this.l_pixel.text = p.toString (); int Height = this.label1.Height; for (int J = 0; J <256; J ) {IF (GL [J]> Height) GL [J] = Height; g.drawline (Pen1, J, Height, J, HEIGHT-GL [J]);} IF Aline) {g.drawline (pens.rangered, xx, 0, xx, height);} if (xx! = - 1) {this.l_sejie.text = xx.toString ();

THISL_HOW.TEXT = this.gray [xx] .tostring (); this.l_bfb.text = this.l [xx] .tostring ();} else {this.l_sejie.text = ""; this.l_how. TEXT = ""; this.l_bfb.text = ";}} private void label1_mousedown (object sender, system.windows.forms.mouseeventargs e) {xx = ex; if (xx> 255) xx = 255; if (xx <= 0) xx = 0; aline = true; this.label1.invalidate ();} private void label1_mousemove (Object sender, system.windows.Forms.MouseEventArgs e) {/ * iv ((EX> 255) && (EX <0) && (EY <0) && (EY> 127)) {this.xx = -1;} else {this.xx = EX;} this.label4.text = ext7tring () " EytoString (); * / Point p = new point (ex, EY); if (New Rectangle (0, 0, 256, 127) .Contains (p)) {this.xx = EX;} else {this.xx = -1;} this .label1.Invalidate ();} private void label1_MouseUp (object sender, System.Windows.Forms.MouseEventArgs e) {aline = false;} private void lcolor_Paint (object sender, System.Windows.Forms.PaintEventArgs e) {int width = THIS.LCOLOR.WIDTH; INT Height = this.lcolor.Height; Int J; Color C; graphics g = E.Graphics; switch (flag) {case 1: {for (int i = width; i> = 0; i -) {j = i; if (j> 255) j = 255; c = color.fromargb (J, J, J); Pen Pen2 = new Pen (C, 1); g.drawline (Pen2, I, 0, i, height);} Break;} case 2: {for (int i = width; I> = 0; I -) {j = i; if (j> 255) j = 255; c = color. FromARGB (J, 0, 0); Pen Pen2 = New Pen (C, 1); g.drawline (Pen2, I, 0, I, Height);} Break;

} Case 3: {for (INT i = width; i> = 0; I -) {j = i; if (j> 255) j = 255; c = color.fromargb (0, j, 0); PEN Pen2 = New Pen (C, 1); g.drawline (Pen2, I, 0, I, Height);} Break;} case 4: {for (int i = width; i> = 0; I -) { J = i; if (j> 255) j = 255; c = color.fromargb (0, 0, j); Pen Pen2 = new Pen (C, 1); g.drawline (Pen2, i, 0, i, height);} break;} default: break;}} private void groupBox1_Paint (object sender, System.Windows.Forms.PaintEventArgs e) {Graphics g = e.Graphics; int x = this.lcolor.Left; int y = this .lcolor.top; Int w = this.lcolor.width; int h = this.lcolor.Height; pointf [] pp = new pointf [4]; pp [0] = new pointf (x, y h 5) ; Pp [1] = new pointf (x-5, y H 15); pp [2] = new pointf (x 5, y h 15); PP [3] = new pointf (x, y h 5); g.fillpolygon (brushes.black, pp); x = W / 2; pp [0] = new pointf (x, y h 5); pp [1] = new pointf (x- 5, Y H 15); PP [2] = New Pointf (x 5, y h 15); PP [3] = new pointf (x, y h 5); g.fil LPOLYGON (Brushes.gray, PP); X = W / 2; PP [0] = New Pointf (x, y h 5); pp [1] = new pointf (x-5, y h 15) PP [2] = new pointf (x 5, y H 15); PP [3] = New Pointf (x, y h 5); g.fillpolygon (brushes.black, pp);} private void button5_Click (object sender, System.EventArgs e) {int a1 = Convert.ToInt32 (this.textBox1.Text); int a2 = Convert.ToInt32 (this.textBox3.Text);} private void undo_Click (object sender, System. Eventargs e) {this.a = (bitmap) this.b.clone ();

转载请注明原文地址:https://www.9cbs.com/read-69025.html

New Post(0)