VC++ 向access中存储图片?

VC++ 向access中存储图片?,第1张

Access的对象“表”中完全可以存放图片!其字段属性就应设置为“OLE对象”,这样就可以将 GIF、JPEG 和其他常见类型的图像文件添加到表中。因为 OLE 对象字段只支持“Windows 位图”(.bmp) 文件和“与设备无关的位图”(.dib) 文件。如果您想将其他类型的图形文件存储到 OLE 对象字段中并让 Access 正确呈现它们,就必须安装其他软件,而该软件必须提供显示其他图像类型所需的组件(被称为 OLE 服务器)。

我也没在数据库中存过图片,上边是在其他地方看到的,你可以尝试百度一下上边的关键词,看看有没有具体的过程或者例子,能帮你的就这些了。

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

int file_size(char* filename)//获取文件名为filename的文件大小。

{

FILE *fp = fopen(filename, "rb")//打开文件。

int size

if(fp == NULL) // 打开文件失败

return -1

fseek(fp, 0, SEEK_END)//定位文件指针到文件尾。

size=ftell(fp)//获取文件指针偏移量,即文件大小。

fclose(fp)//关闭文件。

return size

}

int main ()

{

int size=0

size=file_size("qw")

printf("%d\n",size)

FILE * pFile,*qw

char *buffer=(char*)malloc(sizeof(char)*size)

qw   =fopen("qw","r")

pFile = fopen ( "qwe" , "wb" )

printf("%d==\n",pFile)

printf("%d\n",size)

fread(buffer,1,size,qw)

fwrite (buffer , sizeof(byte), size , pFile )

fclose (pFile)

rename("qwe","Groot.jpg")

return 0

}

扩展资料:

c语言读取TXT文件:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define MAX_LINE 1024

int main()

{

char buf[MAX_LINE]  /*缓冲区*/

FILE *fp            /*文件指针*/

int len             /*行字符个数*/

if((fp = fopen("test.txt","r")) == NULL)

{

perror("fail to read")

exit (1)

}

while(fgets(buf,MAX_LINE,fp) != NULL)

{

len = strlen(buf)

buf[len-1] = '\0'  /*去掉换行符*/

printf("%s %d \n",buf,len - 1)

}

return 0

}

// stdafx.h中包含

#include <atlimage.h>

// 定义

CImage m_image

// 你的图片句柄HBITMAP m_hBmp

m_image.Attach( m_hBmp)

// 要保存的文件名称。全路径

// 保存格式会根据 strPathName文件名的后缀自动判断,

// .JPG, .BMP, .png 等

m_image.Save( strPathName)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8041493.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-12
下一篇2023-04-12

发表评论

登录后才能评论

评论列表(0条)

    保存