RAW格式文件按转换为文本文件

本文详细介绍了如何将RAW格式的数据文件转换成文本文件,包括转换方法、使用的工具和步骤,适合对数据处理和文件转换感兴趣的读者。
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <fstream>
using namespace std;

int g_width = 2448;
int g_height = 2048;

#define NSIZE  8

void Bin2Text(const char* sIn,const char* sOut){
    char buf[1024]; 

    FILE* inFile = fopen(sIn, "rb");
    FILE* outFile = fopen(sOut, "w");

    int count = 0;

    while(1)
    {
        int size = fread(buf, 8, 1, inFile);
        if (size <= 0)
            break;

        count += size;
        for(int i=0; i<size; i++)
        {
            unsigned char c = buf[i];
            fprintf(outFile, "%d ", c);
        } 

        if (count % g_width == 0)
                fprintf(outFile, "\n");
    }
}


int main()
{
    char* raw0 = "E:/bcat/work/zhjpeg/src/zhjpeg/output.raw";
    char* raw1 = "E:/bcat/work/zhjpeg/src/zhjpeg/output11.raw";

    char* out0 = "./raw0.txt";
    char* out1 = "./raw1.txt";

    Bin2Text(raw0, out0);
    Bin2Text(raw1, out1);

    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值