How to use DxfImage and DxfImageDef classes?
![]() 8/8/2007 2:20 PM
|
---|
Hello   I'm working on export of GIS map to DXF. Everything works well until I try to include images in dxf file. Firstly, for every image (in PNG format) I create instance of DxfImageDef class. It looks like that: xfImageDef imageDef = new DxfImageDef(dxfModel); dxfModel.Images.Add(imageDef); Then, whenever I need to place image in dxf I do something like that: DxfImage image = new DxfImage(); dxfModel.Entities.Add(image); Unfortunately, it doesn?t work; I can't see any images in my dxf files. I use few viewers and everywhere effect is the same. Dxf files look properly, I can find IMAGE and IMAGEDEF keywords. However, there is one thing quite alarming for me. In dxf files, produced by AutoCAD, IMAGE and IMAGEDEF section looks completely different. |
![]() 8/8/2007 2:25 PM
|
---|
Hi, I haven't completed the implementation for DxfImage yet (see also on the features page that it's not yet supported by CadLib). I can further work it out and have something by next Monday, would that work for you? Thanks! Wout |
![]() 8/8/2007 2:31 PM
|
---|
Thanks for quick answer. Yes, I can wait for implementation. |
![]() 8/12/2007 8:30 PM
|
---|
Hi, I've done some testing, apparently the writing seems to work with a little modification (had to set ImageIsLoaded to true): C# Code: using System; using System.Collections.Generic; using System.Text; using NUnit.Framework; using WW.Cad.Model; using WW.Cad.Model.Entities; using WW.Cad.Model.Objects; using WW.Cad.IO; using WW.Math; namespace WW.Cad.Test {   [TestFixture]   public class ImageTest {     [Test]     public void TestWrite() {       DxfModel model = new DxfModel();       DxfImageDef imageDef = new DxfImageDef(model);       imageDef.Filename = 'image.png';       imageDef.Name = imageDef.Filename;       imageDef.Size = new Size2D(840d, 525d);       imageDef.DefaultPixelSize = new Size2D(1d, 1d);       imageDef.ImageIsLoaded = true;       model.Images.Add(imageDef);       DxfImage image = new DxfImage();       image.ImageDef = imageDef;       image.InsertionPoint = new Point3D(3d, 2d, 0d);       image.ImageDisplayFlags = ImageDisplayFlags.ShowImage;       model.Entities.Add(image);       DxfWriter.WriteDxf('ImageTest.dxf', model, false);     }   } } Let me know if it works out! Thanks! Wout |
![]() 8/13/2007 11:29 AM
|
---|
Hello   I have just tried this example and it still doesn?t work. In this case, maybe problem is somewhere else. What kind of Cad viewer do you use? |