0
#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();    //

    }
}
4

1 回答 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;

您可以点击以下链接获取更多参考 https://software.intel.com/content/www/us/en/develop/documentation/oneapi-dpcpp-cpp-compiler-dev-guide-and-reference/top/compiler -参考/库/intel-sc-asynchronous-io-extensions-for-windows-operating-systems/intel-sc-asynchronous-io-class-for-windows-operating-systems/example-for-using-async-class -template-class.html

于 2021-09-16T10:30:21.930 回答