小编Mar*_*vdv的帖子

无法读取整个文件

我正在制作一个C++程序,以便能够打开.bmp图像,然后将其放入2D数组中.现在我有这样的代码:

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "Image.h"
using namespace std;

struct colour{
    int red;
    int green;
    int blue;
};

Image::Image(string location){

    fstream stream;
    string tempStr;

    stringstream strstr;
    stream.open(location);

    string completeStr;

    while(!stream.eof()){
        getline(stream, tempStr);
        completeStr.append(tempStr);
    }
    cout << endl << completeStr;

    Image::length = completeStr[0x13]*256 + completeStr[0x12];
    Image::width = completeStr[0x17]*256 + completeStr[0x16];
    cout << Image::length;
    cout << Image::width;
    cout << completeStr.length();

    int hexInt;
    int x = 0x36;
    while(x < completeStr.length()){
        strstr << noskipws << completeStr[x];
        cout << x …
Run Code Online (Sandbox Code Playgroud)

c++ fstream iostream file bmp

1
推荐指数
1
解决办法
3142
查看次数

标签 统计

bmp ×1

c++ ×1

file ×1

fstream ×1

iostream ×1