.NET

Reply
Valued Contributor
Matt S
Posts: 64
Registered: ‎05-05-2004
Message 1 of 4 (282 Views)

DwgPreview / Thumbnail

282 Views, 3 Replies
10-18-2006 12:54 PM
I have followed the advice given in this thread

http://discussion.autodesk.com/thread.jspa?messageID=5316869

in the use of DwgPreview.arx in Acad2006 to save the drawing preview image to a file. Everything works fine, but is there any way to change the image size or image format? I think the dimensions in pixels is something like 180x116, and I would really like to have it smaller, say 94x62.

Is this possible, and is it possible to change the formag from a .BMP to a .JPG?

Any advice is appreciated.
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 4 (282 Views)

Re: DwgPreview / Thumbnail

10-19-2006 06:13 AM in reply to: Matt S
Hi, Matt.
DwgPreview.arx save thumbnail as it existent in dwg-file. You can translate it from BMP to JPG or any format an scale it to any dimensions.
Valued Contributor
Matt S
Posts: 64
Registered: ‎05-05-2004
Message 3 of 4 (282 Views)

Re: DwgPreview / Thumbnail

10-19-2006 06:59 AM in reply to: Matt S
I know I can do that after the fact, but it would be far more convienient to get the image in the format and the size that I want instead of converting lots of image files.

I may just have to do it manually though.
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 4 of 4 (282 Views)

Re: DwgPreview / Thumbnail

10-19-2006 10:41 AM in reply to: Matt S
Size of thumbnail fixed in dwg-file. It is not intresting for me to rewrite DwgPreview.arx in order to it can convert bmp-image to other format and scale it. :smileysad: It is more easy to do converting in C#-code. For example:

[code]
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("dwgpreview.arx", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi ,
EntryPoint = "SaveDWGPreview")]
extern static private int SaveDWGPreview(string dwgfilename, string bmpfilename);
[CommandMethod("SavePreview")]
public void SavePreview()
{
Database db = HostApplicationServices.WorkingDatabase;
Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.LoadModule("DWGPreview.arx", false, false);
SaveDWGPreview(db.Filename, "C:\\dwgpreview.bmp");
System.Drawing.Image img = System.Drawing.Image.FromFile("C:\\dwgpreview.bmp");
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(img,94,62);
img.Dispose(); System.IO.File.Delete("C:\\dwgpreview.bmp");
bm.Save("C:\\dwgpreview.jpg",ImageFormat.Jpeg);
bm.Dispose();
}
[/code]

Also look at this topic: http://www.autocad.ru/cgi-bin/f1/board.cgi?t=29565Fx
Message was edited by: Alexander Rivilis
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.