C#绘图问题,,,急啊

来源:百度知道 编辑:UC知道 时间:2024/05/28 20:13:36
pictureBox1.Location = new System.Drawing.Point(0, 0);
pictureBox1.Size = new System.Drawing.Size(500, 500);
Graphics g = pictureBox1.CreateGraphics();
g.Clear(Color.White);
Bitmap bmp = new Bitmap(Image.FromFile("cross.bmp"));
int x1=0, y1=0, j, i;
// x2 = pictureBox1.Bounds.Right;
x1 = x1 + 10;
y1 = y1 + 10;
int[] Num = new int[10];
SolidBrush sb = new SolidBrush(Color.Black);

Pen pen1 = new Pen(sb, 2);
Pen pen2 = new Pen(sb, 4);

for (i = 0; i < length; i++)
{
g.DrawLine(pen1, x1, y1 + 10 + 40 * i, x1 + 560, y1 + 10 + 40 * i);
}

for (i = 0; i < str.Length; i++)
{
for (j = 0; str[i] != '*'; i++, j++)
{

你可以做一个判断,当你做出来的图大于你指定的大小后就调用一个图像缩放方法,把绘出来的图缩放成合适大小

public static Bitmap GetThumbnail(Bitmap b, int destHeight, int destWidth)
{
System.Drawing.Image imgSource = b;
System.Drawing.Imaging.ImageFormat thisFormat = imgSource.RawFormat;
int sW = 0, sH = 0;
// 按比例缩放
int sWidth = imgSource.Width;
int sHeight = imgSource.Height;

if (sHeight > destHeight || sWidth > destWidth)
{
if ((sWidth * destHeight) > (sHeight * destWidth))
{
sW = destWidth;
sH = (destWidth * sHeight) / sWidth;
}
else
{
sH = destHeight;
sW = (sWidth * destHeight) / sHeight;
}
}
else