如何完全读取图像数据并将其保存在数据库中? [英] How to read the image data fully and saving it in database?

查看:91
本文介绍了如何完全读取图像数据并将其保存在数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码读取图像数据.它的长度是3922126.但是看完之后. b_FileData仅存储三个字节.如何完全读取图像(位图)并将其保存为字节以将其存储在数据库中.

I am using the below code to read the image data. It is of 3922126 length. But after reading it. b_FileData stores only three bytes. How to read the image(bitmap) fully and save it in bytes in order to store it in the database.

     LPBYTE b_FileData = NULL; //File data container
    CFile m_file;
    DWORD l_Filelen;
    m_file.Open(lpszName,CFile::modeRead | CFile::modeNoTruncate);
    m_file.SeekToBegin();

l_Filelen = m_file.GetLength();
b_FileData = new BYTE[l_Filelen];
m_file.Read(b_FileData,l_Filelen);
m_file.Close();//Close the file

推荐答案

我不确定是否将数据存储在数据库中.但是您发布的代码应该可以使用.另外,您如何知道b_FileData具有3个字节的信息.检查
的返回值 m_file.Read(b_FileData,l_Filelen);.如果它等于l_Filelen,则代码正在读取完整文件.
I am not sure about storing the data in database.But code you posted should work.Also, how you know that b_FileData is having 3 bytes of information.Check the return value of
m_file.Read(b_FileData,l_Filelen);.If it is equal to l_Filelen then the code is reading full file.


我认为您在Open调用中缺少CFile::typeBinary
i think you''re missing CFile::typeBinary in your Open call


这篇关于如何完全读取图像数据并将其保存在数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆