二进制读取jpg和写jpg图

代码

#include "stdafx.h"
#include 
#include 
#include 

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	string strpath = "D:\\Dtest5\\Readjpg\\1.jpg";
	string strR1 = "D:\\Dtest5\\Readjpg\\10.jpg";

	std::ifstream fin(strpath.c_str(), std::ios::binary);
	fin.seekg(0, ios::end);
	int iSize = fin.tellg();
	char* szBuf = new (std::nothrow) char[iSize];

	fin.seekg(0, ios::beg);
	fin.read(szBuf, sizeof(char) * iSize);
	fin.close();

	std::ofstream fout(strR1.c_str(), std::ios::binary);
	fout.write(szBuf, sizeof(char) * iSize);
	fout.close();

	return 0;
}


 

 

 

 

你可能感兴趣的:(C++)