本文介绍了如何将表单另存为jpeg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI GUYS。

编写此代码将表单保存为bmp文件:

如果有人知道如何保存像jpeg文件这样的表单说我。



另存为bmp:

HI GUYS.
wrote this code to save a form as a bmp file:
if anybody know how can i save a form like a jpeg file say it to me.

save as a bmp:

private void button1_Click(object sender, EventArgs e)
        {

            this.FormBorderStyle = FormBorderStyle.None;
            this.BackColor = Color.White;

            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.DefaultExt = "*.bmp";
            saveFileDialog.Filter = "bmp Files|*.bmp";
            saveFileDialog.FileName = FormMain.NamProzhe + ".bmp";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                SaveAsBitmap(this, saveFileDialog.FileName);
            }

            this.Close();

        }





保存为位图:



save as bitmap :

public void SaveAsBitmap(Control control, string fileName)
        {
            //getthe instance of the graphics from the control
            Graphics g = control.CreateGraphics();

            //new bitmap object to save the image
            Bitmap bmp = new Bitmap(control.Width, control.Height);

            //Drawing control to the bitmap
            control.DrawToBitmap(bmp, new Rectangle(0, 0, control.Width, control.Height));

            bmp.Save(fileName);
            bmp.Dispose();
        }

推荐答案

private void button1_Click(object sender, EventArgs e)
        {

            this.FormBorderStyle = FormBorderStyle.None;
            this.BackColor = Color.White;

            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.DefaultExt = "*.jpeg";
            saveFileDialog.Filter = "jpeg Files|*.jpeg";
            saveFileDialog.FileName = FormMain.NamProzhe + ".jpeg";

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                SaveAsBitmap(this, saveFileDialog.FileName);
            }

            this.Close();

        }





第一次尝试此代码....再次你被困在这个过程意味着.. 。

访问....



[]


Screen screen = Screen.GetWorkingArea();
Bitmap bmp = new Bitmap(screen.Bounds.Width, screen.Bounds.Height);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(0, 0, 0, 0, bmp.Size);
g.Dispose();
bmp.Save(//path//);





more info @ []


private Bitmap GetImage(Control c)
    {
    Bitmap bmp = new Bitmap(c.Width, c.Height);
    c.DrawToBitmap(bmp, new Rectangle(0, 0, c.Width, c.Height));
    return bmp;
    }
public void myButton_Click(object sender, EventArgs e)
    {
    Image im = GetImage(this);
    im.Save(@"D:\Temp\MyForm.jpg", ImageFormat.Jpeg);
    }


这篇关于如何将表单另存为jpeg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 00:38