#include "block.h" /** * From im, grabs the vertical strip of pixels whose * upper left corner is at position (column,0), and * whose width is width. */ void Block::build(PNG & im, int column, int width){
sh is ar stu ed d v i y re aC s o ou urc rs e eH w er as o. co m
};
int h = im.height(); // first x,then y,copy vertically for (int i = column; i < column + width; i++) { vector<HSLAPixel> temp; for (int j = 0; j < h; j++) { HSLAPixel* p = im.getPixel(i, j); temp.push_back(*p); } data.push_back(temp); } return;
/** * Draws the current block at position (column,0) in im. */ void Block::render(PNG & im, int column) const { for (int i = column; i <column + width(); i++) { for (int j = 0; j < height(); j++) { HSLAPixel* p = im.getPixel(i, j); *p = data[i-column][j]; } } };
/** * This function changes the saturation of every pixel * in the block to 0, which removes the color, leaving grey. */ void Block::greyscale(){ if (data.empty()) {return;}
Th
for(int i = 0; i < width(); i++){ for(int j = 0; j < height(); j++){
HSLAPixel * pixel= &data[i][j]; pixel->s=0; }}
};
/** * Returns the width of the current block. */ int Block::width() const { return data.size(); }; /** * Returns the height of the current block. This study source was downloaded by 100000805705997 from CourseHero.com on 10-15-2021 21:47:45 GMT -05:00
https://www.coursehero.com/file/34808990/blockcpp/