Read the text dot matrix.

xiaoxiao2021-03-06  108

/ ************************************************** ****************************************

*

* CopyRight (C) 2004 Ming Run.

*

* This Software Is Provided 'As-Is', WithOout Any Express or Implied Warranty. In no

* Event will the authors be held liable for (any Damages Arising from the use of this

* Software.

*

* Permission is granted to anyyone to use this software for (any purpose, including

* Commercial Applications, And to ALTER IT and Redistribute It Free, Subject To The

* FOLLOWING RESTRICTIONS:

*

* 1. The Origin of this Software Must Not Be misrepreprepreprepreprepreted; you must not claim That

* You Wrote the Original Software. if you use this software in a product, an

* Acknowledgment (See the Following) In The Product Documentation is Required.

*

* CopyRight (C) 2004 Ming Run.

*

* 2. Altered Source Versions Must Be Plainly Marked As Such, And Must Not Be

* Misrepresented as being the original software.

*

* 3. This Notice May Not Be Removed or Altered from Any Source Distribution.

*

*********************************************************** ******************************* /

Import system;

Import system.drawing;

Import system.windows.forms;

Import NUnit.framework;

Package Runmin.sample

{

Class ImageApplication Extends Form

{

PRIVATE VAR TOPPANEL: PANEL = New Panel ();

PRIVATE VAR BOTTOMPANEL: PANEL = New Panel ();

Private var button: button = new button ();

Private var richtextbox: richtextbox = new richtextbox ();

Private var textbox: TextBox = new textbox ();

Public function imageApplication ()

{

"" Sample Application. ");

}

Public Function ImageApplication (CAPTION: STRING)

{

THIS.TEXT = CAPTION;

this.dockpadding.all = 5; this.windowstate = 2;

This.Controls.add (this.toppanel);

This.Controls.add (this.bottompanel);

THIS.TOPPANEL.DOCK = 5;

THIS.BOTTOMPANEL.DOCK = 2;

this.bottompanel.size = new system.drawing.size (0, 18);

This.button.dock = 4;

THIS.BUTTON.FLATSTYLE = 1;

This.Button.Text = "process";

this.TextBox.dock = 4;

this.TextBox.Borderstyle = 1;

this.TextBox.maxlength = 1;

this.richtextbox.dock = 5;

this.richtextbox.wordwrap = false;

this.richtextbox.font = new system.drawing.font ("Courier New", 8);

THIS.TOPPANEL.CONTROLS.ADD (this.richtextbox);

This.bottompanel.controls.add (this.TextBox);

This.bottompanel.controls.add (this.button);

This.button.add_click (this.button_click);

}

Private function button_click (sender, e: Eventargs)

{

VAR DIALOG: FONTDIALOG = New fontdialog ();

Dialog.showdialog ();

Var Bitmap: Bitmap = New Bitmap (150, 150);

Var Graphics: graphics = graphics.fromimage (bitmap);

Graphics.drawstring (this.textbox.text, dialog.font, brushes.black, 0, 0);

Var Result: system.text.stringbuilder = new system.text.stringbuilder ();

VAR x: int = 0;

VAR Y: INT = 0;

For (x = 0; x

{

For (y = 0; y

{

IF (Bitmap.getpixel (Y, X) .toargb () == 0) Result.Append ("");

Else Result.Append ("*");

}

Result.Append ("/ n");

}

this.richtextbox.text = result.tostring ();

}

}

}

Application.run (New Runmin.sample.ImageApplication ());

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

New Post(0)