.NET

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

DwgPreview / Thumbnail

273 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 (273 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 (273 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 (273 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community