insert bitmap in cadimage

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
lulu
Posts: 25
Joined: 12 Nov 2009, 19:55

insert bitmap in cadimage

Post by lulu » 30 Apr 2010, 19:58

Hi,

I need to convert a bitmap into a cadentity, to insert it in my cadimage. is there a method to do this conversion? if it doesn't exist, can I insert the bitmap directly in my cadimage?

thank you,
lulu.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: insert bitmap in cadimage

Post by support » 04 May 2010, 12:28

Hello lulu.
Bitmap or other raster can be added into CADImage object as an ImageEnt object:

Code: Select all

            if (this.cadImage == null)
            {
                this.cadImage = new CADImage();
                this.cadImage.InitialNewImage();
            }
            this.cadImage.UseDoubleBuffering = false;

            CADImageEnt entRaster = new CADImageEnt();
            string tmp = your_file;
            Bitmap bmpTmp;
            if (!System.IO.File.Exists(tmp)) return;            
            try
            {
                bmpTmp = new Bitmap(tmp);
            }
            catch
            {
                return;
            }
            CADImageDef def = new CADImageDef();
            def.FileName = tmp;
            def.Loaded(this.cadImage.Converter);            
            entRaster.ImageDef = def;            
            entRaster.Color = CADConst.clNone;
            entRaster.Point = new DPoint(0, 0, 0);
            entRaster.Size = new DPoint(bmpTmp.Width, bmpTmp.Height, 0);            
            entRaster.Rotate = 0;           
            entRaster.Loaded(this.cadImage.Converter);

            this.cadImage.Converter.ImageDefs.Add(entRaster.ImageDef);
            this.cadImage.Converter.OnCreate(entRaster);
            this.cadImage.CurrentLayout.AddEntity(entRaster);
            this.cadPictBox.Invalidate();
there is also DoResize method within demo applications to correct sizes ratio if necessary.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply