乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 58|回复: 3

求助如何提取dwg文件中的bmp文件,预览dwg文件

[复制链接]

3

主题

4

帖子

2

银币

初来乍到

Rank: 1

铜币
16
发表于 2007-9-4 13:24:00 | 显示全部楼层 |阅读模式
求助如何提取dwg文件中的bmp文件,预览dwg文件
谢谢
回复

使用道具 举报

16

主题

909

帖子

8

银币

中流砥柱

Rank: 25

铜币
973
发表于 2007-9-6 07:02:00 | 显示全部楼层
DwgThumbnail CONTROL
回复

使用道具 举报

13

主题

107

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
159
发表于 2007-9-11 09:30:00 | 显示全部楼层
you kongjian!!
回复

使用道具 举报

11

主题

326

帖子

9

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
370
发表于 2007-9-11 16:42:00 | 显示全部楼层
Option Explicit
Private Type BITMAPINFOHEADER
        biSize As Long
        biWidth As Long
        biHeight As Long
        biPlanes As Integer
        biBitCount As Integer
        biCompression As Long
        biSizeImage As Long
        biXPelsPerMeter As Long
        biYPelsPerMeter As Long
        biClrUsed As Long
        biClrImportant As Long
End Type
Private Type BITMAPFILEHEADER
        bfType As Integer
        bfSize As Long
        bfReserved1 As Integer
        bfReserved2 As Integer
        bfOffBits As Long
End Type
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private mvarPicture As PictureBox
Dim mvarBuffer() As Long
Dim mvarPictureType As Integer
Dim mvarFileName As String
Public Function GetDrawingPreview(dwgPath As String, Tmppath As String) As Boolean
On Error GoTo errH
    Dim fh As Integer, tmpBuffer() As Byte, i As Long
    Dim biHeader As BITMAPINFOHEADER, ver As Integer
    Dim sentinel As Long, nOffset As Long, imageSize As Long
    Dim tmp As Long, previewType As Byte, retval As Boolean
    mvarFileName = Tmppath
    If Dir$(dwgPath, vbNormal) = "" Then
'        mvarErrorCode = vbObjectError + 6
'        mvarErrorText = "File not found"
        retval = False
    Else
        fh = FreeFile
        Open dwgPath For Binary As #fh
        ' Read the first 18 bytes of the drawing
        ReDim tmpBuffer(0 To 17)
        Get #fh, , tmpBuffer
        ' Ensure that the drawing is at least R14
        ver = Val(Chr(tmpBuffer(4)) & Chr(tmpBuffer(5)))
        If ver  0 Then
                                ' Of the 39 bytes, bytes 31 through 34 contain the
                                ' starting location of the preview image data
                                CopyMemory nOffset, tmpBuffer(UBound(tmpBuffer) - 8), 4
                                ' Bytes 35 through 39 contain the size of the image data
                                CopyMemory imageSize, tmpBuffer(UBound(tmpBuffer) - 4), 4
                                tmp = UBound(tmpBuffer)
                                ' Retrieve the preview data
                                ReDim tmpBuffer(0 To imageSize + nOffset - tmp)
                                Get #fh, , tmpBuffer
                                Close #fh
                                ReDim mvarBuffer(0 To imageSize - 1)
                                ' Isolate the image data
                                CopyMemory mvarBuffer(0), tmpBuffer(nOffset - tmp - 1), imageSize
                                ' and make a bitmap file from it
                                WriteImage
                                ' Load it
                                'Set Form1.Picture1.Picture = LoadPicture(mvarFileName)
                                ' Delete it
                                'Kill mvarFileName
                                retval = True
                         End If
        End If
    End If
errH:
    GetDrawingPreview = retval '& vbCrLf & mvarFileName
End Function
Private Sub WriteImage()
On Error Resume Next
    Dim fh As Integer, bfHeader As BITMAPFILEHEADER
    Dim biHeader As BITMAPINFOHEADER, clrTableSize As Long
    Dim i As Integer, tmp As String, pixels As Long
    'Dim mvarBuffer(10) '''''''-----------
    'If mvarPictureType = IVW_PREVIEWBITMAP Then
        ' Copy the BITMAPINFOHEADER from the buffer into a structure
        CopyMemory biHeader, mvarBuffer(0), 40
        clrTableSize = IIf(biHeader.biBitCount
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 02:34 , Processed in 1.205917 second(s), 61 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表