void Image_VGA_Planar::convert(const Pixels& newContent, const Pixels& newMask) { auto dims = this->dimensions(); unsigned long dataSize = dims.x * dims.y; stream::pos len = this->content->size(); // Cut off any leftover data or resize so there's enough space if (dataSize + this->off != len) { this->content->truncate(dataSize + this->off); } // else size didn't need to change, e.g. fixed-size VGA image Pixels pix; pix.resize(dataSize, 0); // Convert the linear data to planar unsigned int planeWidth = dims.x / 4; unsigned int planeSize = planeWidth * dims.y; for (unsigned int i = 0; i < dataSize; i++) { pix[i] = newContent[i % planeSize * 4 + i / planeSize]; } this->content->seekp(this->off, stream::start); this->content->write(pix.data(), dataSize); return; }
Pixels Image_SW93Beta_BG_Planar::convert_mask() const { int dataSize = SWBGP_WIDTH * SWBGP_HEIGHT * 4; // Return an entirely opaque mask Pixels pix; pix.resize(dataSize, 0); return pix; }
Pixels Image_VGA_Planar::convert_mask() const { auto dims = this->dimensions(); int dataSize = dims.x * dims.y; // Return an entirely opaque mask Pixels pix; pix.resize(dataSize, 0); return pix; }
int main(int argc, char* argv[]) { if(argc < 3) { cout << "Uso: ./main <archivo de entrada> <archivo de salida>" << endl; return 0; } int metodo = 1; if(argc > 3) { metodo = int(atoi(argv[3])); } std::ifstream inputFile(argv[1]); int rows, cols; inputFile >> cols >> rows; Pixels pixels; uint color; pixels.resize(rows); for(int i=0; i<rows; i++) { pixels[i].resize(cols); for(int j=0; j<cols; j++) { pixels[i][j].red = pixels[i][j].green = pixels[i][j].blue = 0; inputFile >> color; if(i%2 == 0) { if(j%2 == 0) { pixels[i][j].blue = color; } else { pixels[i][j].green = color; } } else { if(j%2 == 0) { pixels[i][j].green = color; } else { pixels[i][j].red = color; } } } } inputFile.close(); if(metodo == 1) { nearestNeighbour(pixels, RED); nearestNeighbour(pixels, GREEN); nearestNeighbour(pixels, BLUE); } else if(metodo == 2) { bilinear(pixels, RED); bilinear(pixels, GREEN); bilinear(pixels, BLUE); } else if(metodo == 3) { bilinear(pixels, RED); bilinear(pixels, BLUE); directional_interpolation(pixels); } else if(metodo == 4) { bilinear(pixels, RED); bilinear(pixels, BLUE); MHC(pixels); } else { nearestNeighbour(pixels, RED); nearestNeighbour(pixels, GREEN); nearestNeighbour(pixels, BLUE); } std::ofstream outputFile(argv[2]); outputFile << cols << " " << rows << endl; for(int i=0; i<rows; i++) { for(int j=0; j<cols; j++) { outputFile << pixels[i][j].red << " " << pixels[i][j].green << " " << pixels[i][j].blue << endl; } } outputFile.close(); return 0; }