大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
画点:
创新互联公司为企业级客户提高一站式互联网+设计服务,主要包括成都做网站、成都网站建设、成都app软件开发、重庆小程序开发、宣传片制作、LOGO设计等,帮助客户快速提升营销能力和企业形象,创新互联各部门都有经验丰富的经验,可以确保每一个作品的质量和创作周期,同时每年都有很多新员工加入,为我们带来大量新的创意。
在PictureBox的Paint事件里面:
dim myGraphics=e.Graphics
Dim myPointArray As Point() = {New Point(0, 0), New Point(50, 30), New Point(30, 60)}
myGraphics.DrawPolygon(myPen, myPointArray)
画圆:
Dim g As Graphics
g = PictureBox1.CreateGraphics
g.FillEllipse(Brushes.Red, x, y, 10, 10)
Dim b As New Bitmap(320, 200)'定义图像宽高
Dim clrs As Color=Color.Black
for y as int32=1 to 199
for x as int32=1 to 319
if x=y then
clrs = Color.White'假设是对角线,x=y时使用白色
else
clrs = Color.Black'平时使用黑色
endif
b.SetPixel(x, y, clrs)'画点
next
next
b.Save("test.tif", System.Drawing.Imaging.ImageFormat.Tiff)'保存到图片文件
==================
原创例子,祝进步!!
namespace Linfo
{
public partial class VerifyCode : BasePage
{
public Random rand = new Random();
protected void Page_Load(object sender, EventArgs e)
{
string strListCode = "0123456789abcdefghigklmnopqrstuvwxyz";
int num = 0;
string strNum = num.ToString();
string strListNum = "";
for (int i = 0; i = 3; i++)
{
num = this.rand.Next(1, 36);
strListNum = strListNum + strListCode.Substring(num - 1, 1);
}
this.Session["checkcode"] = strListNum;
base.Response.Cookies.Add(new HttpCookie("CheckCode", SHA1(strListNum)));
this.CreateImage(strListNum);
}
private void CreateImage(string checkCode)
{
int iwidth = checkCode.Length * 8;
Bitmap image = new Bitmap(70, 30);
Graphics g = Graphics.FromImage(image);
g.SmoothingMode = SmoothingMode.HighQuality;
Font f = new Font("Arial ", 14f, FontStyle.Bold);
Brush b = new SolidBrush(Color.Black);
Rectangle rect = new Rectangle(0, 0, 80, 30);
HatchBrush hatchBrush = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.LightGray, Color.LightSkyBlue);
g.FillRectangle(hatchBrush, rect);
float CPostion = 1f;
for (int i = 0; i checkCode.Length; i++)
{
this.TransformG(g);
SizeF size = g.MeasureString(checkCode[i].ToString(), f);
g.DrawString(checkCode[i].ToString(), f, b, CPostion, 5f);
CPostion += size.Width - 1f;
g.ResetTransform();
}
MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Jpeg);
g.Dispose();
image.Dispose();
base.Response.ClearContent();
base.Response.ContentType = "image/Jpeg";
base.Response.BinaryWrite(ms.ToArray());
}
private void TransformG(Graphics g)
{
Matrix myMatrix = new Matrix();
int num1 = this.rand.Next(80, 900);
int num2 = this.rand.Next(80, 800);
float dd1 = num1;
float dd2 = num2;
dd1 /= 10000f;
dd2 /= 10000f;
float f1 = dd1;
float f2 = dd2;
myMatrix.Shear(f1, f2);
g.MultiplyTransform(myMatrix);
}
}
}
你可以通过用VB.net控制excel,让excel生成曲线图,然后利用excelVBA将图输出,最后导入到VB.net就可以了。
.NET确实没有提供画一个像素点得方法
你可以试一下用FillEllipse填充一个宽1像素,高2像素的椭圆
原理就是FillEllipse的时候,最左边那一列一般都会多出一个一像素的点;高至少要2,少了就什么都画不出来
自己用GDI+画的 无论什么什么尺寸的picturebox都行
不过别太小了o(∩_∩)o
代码放在哪里自己决定啊
最好是放在 picturebox的resize时间里
每次picturebox大小改变都重画一次坐标
Dim b As New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim g As Graphics = Graphics.FromImage(b)
g.Clear(Color.White)
Dim p As New Pen(Color.Black)
p.EndCap = Drawing2D.LineCap.ArrowAnchor
g.DrawLine(p, 30, PictureBox1.Height - 30, 30, 30)
g.DrawLine(p, 30, PictureBox1.Height - 30, PictureBox1.Width - 30, PictureBox1.Height - 30)
Dim i As Integer
Dim bs As New SolidBrush(Color.Green)
Dim po As New Point
po.X = 0
po.Y = PictureBox1.Height - 35
For i = 700 To 1000 Step 50
g.DrawString(i, Me.Font, bs, po.X, po.Y)
g.DrawLine(p, po.X + 28, po.Y + 5, po.X + 30, po.Y + 5)
po.Y -= (PictureBox1.Height - 100) / 6
Next
po.X = 30
po.Y = PictureBox1.Height - 30
For i = 0 To 40 Step 5
g.DrawString(i, Me.Font, bs, po.X, po.Y + 5)
g.DrawLine(p, po.X, po.Y + 2, po.X, po.Y)
po.X += (PictureBox1.Width - 100) / 8
Next
PictureBox1.Image = b