#include <chrono>
#include <algorithm>
#include <CL/sycl.hpp>
using namespace sycl;
using namespace std::chrono;
using namespace std;
#include <iostream>
#include <fstream>
#include <sstream>
static const int x = 250;
static const int y = 250;
int main()
{
queue q; //create queue
std::cout << "Device: " << q.get_device().get_info<info::device::name>() << std::endl;
std::ofstream image;
image.open("Saltpepper.pgm");
//while open
if (image.is_open()) {
//header info
image << "P3" << std::endl;
image << "250 250" << std::endl;
image << "255" << std::endl;
//to do parallel execution ?
q.parallel_for(range<1>(x), [=](id<1> i) {
std::image << (x * y) % 255 << " " << (x * y) % 255 << " " << (x * y) % 255 << std::endl;
}
std::image.close(); //
}
}
问问题
63 次
1 回答
0
如果您想访问您的图像文件,您可以通过以下方式使用它们
/ Data is array of floats
std::vector<float> v(10000);
// User defines new operator << for std::vector<float> type
std::ofstream& operator << (std::ofstream & str, std::vector<float> & vec)
{
// User’s output actions
...
}
...
// Output file declaration – object of standard ofstream STL class
std::ofstream external_file(“output.txt”);
...
// Output operations
external_file << v;
于 2021-09-16T10:30:21.930 回答