示例#1
0
文件: frame.cpp 项目: Doralitze/CREP
Frame::Frame(Dimension &size, RGBAPixel* initColor){
    this->width = size.GetWidth();
    this->height = size.GetHeight();
    if(getAllPlatforms().size() == 0){
        std::cout << " No platforms found. Check OpenCL installation!" << std::endl;
        return;
    }
#ifdef FK_USE_VECTOR_IMP
    //this->data = new std::vector<std::vector<HSVPixel>>();
    data.resize(width);
    for(unsigned int x = 0; x < this->width; x++){
        //std::vector<HSVPixel*>* nvector = new std::vector<HSVPixel*>;
        data[x].resize(height);
        //this->data->push_back(nvector);
        for(unsigned int y = 0; y < this->height; y++){
            //HSVPixel* pixel = new HSVPixel();
            //nvector->push_back(pixel);
            if(initColor != nullptr){
                data[x][y].setRed(initColor->getRed());
                data[x][y].setGreen(initColor->getGreen());
                data[x][y].setBlue(initColor->getBlue());
                data[x][y].setAlpha(initColor->getAlpha());
            } else {
                data[x][y].setRed(255);
                data[x][y].setGreen(255);
                data[x][y].setBlue(255);
                data[x][y].setAlpha(255);
            }
        }
    }
#else
    data = new double[width][height][4];
    if(initColor != nullptr)
        for(unsigned int x = 0; x < this->width; x++)
            for(unsigned int y = 0; y < this->height; y++){
                data[x][y][0] = initColor->getRed();
                data[x][y][1] = initColor->getGreen();
                data[x][y][2] = initColor->getBlue();
                data[x][y][3] = initColor->getAlpha();
            }
#endif
    valid = true;
}