如何用vc把图片读取成16进制字符串
怎么用vc把图片读取成16进制字符串
怎么用vc把图片读取成16进制字符串, (不是BS64编码或别的)
我想在RTF中直接写入图片信息,需要把图片读取成16进制字符串,请高手帮忙
------解决方案--------------------
直接%02X编码,每2个字符代表一个字节。
不过RTF中这样出来的不是图片
------解决方案--------------------
BYTE *buff=NULL;
CFile file;
file.Open(...);
int nlen=file.GetLenth();
buff=new BYTE[nlen+1];
file.read(buff,nlen+1);
file.SeeKto(位图中数据开始的地方)
file.Read(buff,FILELEN);
------解决方案--------------------
从msdn上改写
怎么用vc把图片读取成16进制字符串, (不是BS64编码或别的)
我想在RTF中直接写入图片信息,需要把图片读取成16进制字符串,请高手帮忙
------解决方案--------------------
直接%02X编码,每2个字符代表一个字节。
不过RTF中这样出来的不是图片
------解决方案--------------------
BYTE *buff=NULL;
CFile file;
file.Open(...);
int nlen=file.GetLenth();
buff=new BYTE[nlen+1];
file.read(buff,nlen+1);
file.SeeKto(位图中数据开始的地方)
file.Read(buff,FILELEN);
------解决方案--------------------
从msdn上改写
- C/C++ code
#include <stdio.h> void main( void ) { FILE *stream; char list[3000]; int i, numread, numwritten; if( (stream = fopen( "fread.bmp", "rb" )) != NULL ) { int len = _filelength(_fileno(stream)); numread = fread( list, sizeof( char ), len, stream ); printf( "Number of items read = %d\n", numread ); printf( "Contents of buffer = %.25s\n", list ); fclose( stream ); } else printf( "File could not be opened\n" ); }
------解决方案--------------------
C/C++ code#include <stdio.h>
void main( void )
{
FILE *stream;
char list[3000];
int i, numread, numwritten;
if( (stream = fopen( "fread.bmp", "rb" )) != NULL )
{
int len = _filelength(_fileno(stream));
numread = fread( list, sizeof( char ), len, stream );
printf( "Number of items read = %d\n", numread );
printf( "Contents of buffer = %.25s\n", list );
fclose( stream );
}
else
printf( "File could not be opened\n" );
}