设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

12下一页
返回列表 发新帖
查看: 10840|回复: 13
打印 上一主题 下一主题

[模块/函数] [源码共享]导出Access图片控件的图片到文件

[复制链接]

点击这里给我发消息

跳转到指定楼层
1#
发表于 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 订阅订阅

点击这里给我发消息

2#
发表于 2013-11-13 15:50:16 | 只看该作者
谢谢分享
回复

使用道具 举报

点击这里给我发消息

3#
 楼主| 发表于 2013-11-13 17:35:37 | 只看该作者
谢谢 淘贴 收藏
4#
发表于 2014-4-28 21:57:19 来自手机 | 只看该作者
谢谢楼主分享来自: Android客户端
5#
发表于 2014-5-13 22:33:18 | 只看该作者
好好学习,天天向上
6#
发表于 2014-7-3 07:43:47 | 只看该作者
好好学习,天天向上
7#
发表于 2016-7-10 00:41:37 | 只看该作者
好好好呵呵呵呵呵
8#
发表于 2016-7-10 00:42:17 | 只看该作者
好好好呵呵呵呵呵
9#
发表于 2016-8-3 17:28:19 | 只看该作者
学习提高
回复

使用道具 举报

10#
发表于 2016-8-23 15:20:33 | 只看该作者
谢谢分享
回复

使用道具 举报

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

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-2 23:10 , Processed in 0.101973 second(s), 39 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表