bmp2dat_gray.cpp

来自「图象的均值滤波」· C++ 代码 · 共 40 行

CPP
40
字号
// bmp2dat_gray.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>


using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	FILE *in;
	errno_t err; 
	err = fopen_s(&in,"./gray3noised.bmp","r");
	ofstream out("gray3.dat");
	
	fseek(in,0,SEEK_END);
	int size=0,datastart=0x0436-1;
	size = ftell(in);
	unsigned int ch;
	unsigned char ach;
	out<<"1651 1 0 0 0"<<endl;
	for(long i=size-1;i>datastart;i--)
	{
		fseek(in,i,SEEK_SET);
		ch = fgetc(in);
		ach=ch;
		ch=ach;
		out<<"0x"<<setw(4)<<setfill('0');
		out<<hex<<ch<<endl;
		out.flush();
	}
	out.close();
	
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?