提问人:Cooper Maira 提问时间:11/18/2023 更新时间:11/18/2023 访问量:36
选择性 stream.read() 与一个长 stream.read()
Selective stream.read()s vs one long stream.read()
问:
我正在从我注册然后放置的数千个单独的帧中构建一个合成图像。单个帧约为 6400x4800 像素,但最终仅为最终合成图像贡献约 200x500 像素。我通过构建合成图像的 voronoi 图/zbuffer,然后将区域映射回贡献帧,提前确定各个帧的哪些部分将进入合成图像。在我需要从磁盘加载图像数据之前,我会这样做。这就产生了一种情况,即我想从磁盘中读取一小块不连续的内存。怎么做?
做这样的事情会更快吗:
stream.open(image_file_path, std::ios::binary);
stream.read(raw_buffer, width*height);
stream.close();
或者这样做是否值得:
for(unsigned int i = 0; i < region.height; i++){
stream.seekg(read_location);
stream.read(&raw_buffer[i * region.width], region.width);
read_location += width;
}
stream.close();
答: 暂无答案
评论
madvise