newer 发表于 2021-1-11 20:35:15

Accessing the DWG thumbnail image (preview image)


问题:
How do I extract the DWG thumbnail image? Is an OCX control available I can
use to display the image in my dialog boxes?

解答:
The following lists the different methods for accessing the DWG thumbnail image:

Method #1
Use the ObjectARX API's acdbDisplayPreviewFromDwg() function to display a preview
image, but you need to use MFC. See DevNote #5298 for a detailed sample.

Method #2
Use the DWGThumbnail ActiveX control to view AutoCAD DWG preview images in any
ActiveX control container, such as VB. You'll find the DwgThumbnail OCX control
in the ADN web site using the Knowledge Base. (AutoCAD Utility Apllication)

Method #3
This method is the more powerful of the fourth methods detailed in this DevNote
because it uses the last technology of Autodesk product and displays the drawing
content rather than just the preview image. It uses the VoloView OCX control.
It also requires that VoloView or VoloView Express to be installed on your computer
(VoloView Express is for free!).

Download VoloView Express from the Autodesk web site at http://www.autodesk.com

Method #4
Examine the code that follows to learn how theDWG preview image information
(thumbnail image) is stored in AutoCAD DWG files. Note that this information
is subject to change without notice in future versions of AutoCAD.

*** DWG Preview Image Information ***
Offset 14 in the dwg (if you start counting from 1) contains a long which points
to the thumbnail sentinel.

Following the 16-byte sentinel are 4 bytes containing the size of of the
thumbnail data (excluding the sentinels).

Next, a single byte that contains the number of thumbnail objects follows. After
that, an array of thumbnail object descriptors follows, which is just a block
that describes what type of object it is, its offset in the dwg, and its size.
The object descriptors, and their data, can be in any order. The current types
are:

1. Title - A minimum of 80 bytes that may be used to describe the drawings
contents. Even if the title has fewer than 80 characters, 80 bytes of space is
always allocated.

2. BMP - A bitmap image of the drawing is actually everything in a BMP file
except for the BITMAPFILEHEADER. Any type is allowed, but the ones Autodesk
products write have 256 colors, and are compressed using BI_RLE8 format.

3 - WMF - A Windows metafile with the 22 byte Aldus header.

Afterwards, all the data for the formats are specified. What follows the data
next is another thumbnail sentinel that has its bits inverted.


+-------------------------------------------------------------------+
| thumnail sentinel - 16 bytes                        |
+-------------------------------------------------------------------+
| size of thumnail data - 4 bytes                  |
+-------------------------------------------------------------------|
| number of thumbnail objects - 1 byte                  +
+-------------------------------------------------------------------+
| array of thumbnail | type of object - 1byte                |
| object descriptors +----------------------------------------------+
|             | offset of object from start of dwg - 4 bytes |
| (0 thru n - 1)   +----------------------------------------------+
|             | size of object - 4 bytes             |
+--------------------+----------------------------------------------+
| thumbnail data for objects 0 thru n - 1                |
+-------------------------------------------------------------------+
| inverse thumbnail sentinel                        |
+-------------------------------------------------------------------+



/db_自贡黄明儒_ 发表于 2021-1-11 21:15:41

N版呀,既然搞过来,想必您全看懂了,来个示例好不好?怎么搞"缩略图",既然能搞,就可独显示块,或者组,或者一部分对象,那就很有用处了。
页: [1]
查看完整版本: Accessing the DWG thumbnail image (preview image)