Click here to Skip to main content
14,329,910 members
Rate this:
Please Sign up or sign in to vote.

I'm editing a image, loading it in a pictureBox. When i've done the changes i want to save the image as a .dwg file, but when i want to open the file AUTOCAD doesnt recognise so i'm not able to open the file on AUTOCAD. Is there any way which i can obtain a correct .dwg file, from a edited image in c#?

This is the code that i'm using to obtain the .dwg file, it works for jpg file, but not for .dwg file
private void Generar_Click(object sender, EventArgs e)
            SaveFileDialog Guardar = new SaveFileDialog();
            Guardar.Filter =    "DWG(*.dwg)|*DWG|DXG(*.DXG)|*.DXG|JPEG(*.JPG)|*.JPG|BMP(*.BMP)|*.BMP";
            Bitmap bmp = new Bitmap(pictureBox.Image);
            Graphics gr = Graphics.FromImage(bmp);
            Pen p = new Pen(Color.Red);
            p.Width = 5.0f;
            gr.DrawRectangle(p, 1, 2, 30, 40);
            pictureBox.Image = bmp;
            Image Imagen = pictureBox.Image;


1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Unless you have a library that knows how to write a DWG file, you're going to have to write one. The built in stuff in .NET doesn't know anything at all about how to write a DWG file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100