In the archive from https://drive.google.com/file/d/1Lkzvs0 ... sp=sharing are two dwg files - one from AutoCAD and the other from Inventor.
How to extract the thumbnail:
*** 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.
Code: Select all
+-------------------------------------------------------------------+
| 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 |
+-------------------------------------------------------------------+
NOTE: A very nice and clear code to extract the DWG thumbnail in... ...Visual Basic (!) is to be found as the answer of the question raised here:
https://social.msdn.microsoft.com/Forum ... sexpressvb
Another piece of code (perhaps newer) to read the DWG thumb, again in Visual Basic (!), is to be found here:
https://social.msdn.microsoft.com/Forum ... =vbgeneral
...and finally some braces code here: (be sure to read the entire thread) - START WITH THIS THREAD:
http://www.theswamp.org/index.php?topic=30985.15
It is .NET but you can easily convert it to native C++