設為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

12下一頁
返回列表 發(fā)新帖
查看: 12741|回復: 13
打印 上一主題 下一主題

[模塊/函數] [源碼共享]導出Access圖片控件的圖片到文件

[復制鏈接]

點擊這里給我發(fā)消息

跳轉到指定樓層
1#
發(fā)表于 2013-11-13 15:39:30 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
Image圖片控件可指定圖片路徑,但設置后,如果源文件刪除,就無法將這個圖片導出來,這個源碼可將圖片再導出來

一. 導出到PNG文件格式

Public Function savePict(pImage As Access.Image)
    Dim fname As String 'The name of the file to save the picture to
    fname = Environ("Temp") + "\temp.png" ' Destination file path

    Dim iFileNum As Double
    iFileNum = FreeFile 'The next free file from the file system

    Dim pngImage As String 'Stores the image data as a string
    pngImage = StrConv(pImage.PictureData, vbUnicode) 'Convert the byte array to a string

    'Writes the string to the file
    Open fname For Binary Access Write As iFileNum
        Put #iFileNum, , pngImage
    Close #iFileNum
End Function

二.導出到 EMF文件格式
Public Function savePict(pImage As Access.Image)
    Dim fname As String 'The name of the file to save the picture to
    Dim iFileNum As Double
    Dim bArray() As Byte, cArray() As Byte
    Dim lngRet As Long

    fname = Environ("Temp") + "\temp.emf" ' Destination file path
    iFileNum = FreeFile 'The next free file from the file system

    ' Resize to hold entire PictureData prop
    ReDim bArray(LenB(pImage.PictureData) - 1)
    ' Resize to hold the EMF wrapped in the PictureData prop
    ReDim cArray(LenB(pImage.PictureData) - (1 + 8))
    ' Copy to our array
    bArray = pImage.PictureData
    For lngRet = 8 To UBound(cArray)
        cArray(lngRet - 8) = bArray(lngRet)
    Next

    Open fname For Binary Access Write As iFileNum
    'Write the byte array to the file
    Put #iFileNum, , cArray
    Close #iFileNum
End Function

本帖被以下淘專輯推薦:

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享分享 分享淘帖1 訂閱訂閱

點擊這里給我發(fā)消息

2#
發(fā)表于 2013-11-13 15:50:16 | 只看該作者
謝謝分享
回復

使用道具 舉報

點擊這里給我發(fā)消息

3#
 樓主| 發(fā)表于 2013-11-13 17:35:37 | 只看該作者
謝謝 淘貼 收藏
4#
發(fā)表于 2014-4-28 21:57:19 來自手機 | 只看該作者
謝謝樓主分享來自: Android客戶端
5#
發(fā)表于 2014-5-13 22:33:18 | 只看該作者
好好學習,天天向上
6#
發(fā)表于 2014-7-3 07:43:47 | 只看該作者
好好學習,天天向上
7#
發(fā)表于 2016-7-10 00:41:37 | 只看該作者
好好好呵呵呵呵呵
8#
發(fā)表于 2016-7-10 00:42:17 | 只看該作者
好好好呵呵呵呵呵
9#
發(fā)表于 2016-8-3 17:28:19 | 只看該作者
學習提高
回復

使用道具 舉報

10#
發(fā)表于 2016-8-23 15:20:33 | 只看該作者
謝謝分享
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2025-7-13 08:00 , Processed in 0.099032 second(s), 37 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表