Office中國(guó)論壇/Access中國(guó)論壇

 找回密碼
 注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

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

[模塊/函數(shù)] [源碼共享]導(dǎo)出Access圖片控件的圖片到文件

[復(fù)制鏈接]

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

跳轉(zhuǎn)到指定樓層
1#
發(fā)表于 2013-11-13 15:39:30 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
Image圖片控件可指定圖片路徑,但設(shè)置后,如果源文件刪除,就無(wú)法將這個(gè)圖片導(dǎo)出來(lái),這個(gè)源碼可將圖片再導(dǎo)出來(lái)

一. 導(dǎo)出到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

二.導(dǎo)出到 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

本帖被以下淘專(zhuān)輯推薦:

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

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

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

使用道具 舉報(bào)

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

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

使用道具 舉報(bào)

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

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則

QQ|站長(zhǎng)郵箱|小黑屋|手機(jī)版|Office中國(guó)/Access中國(guó) ( 粵ICP備10043721號(hào)-1 )  

GMT+8, 2024-10-23 06:17 , Processed in 0.095887 second(s), 39 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復(fù) 返回頂部 返回列表