Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write two C++ functions that create or modify an existing image using the PhotoChop code. (Inverted & Flip Vertically) Invert : Set each color to

Write two C++ functions that create or modify an existing image using the PhotoChop code. (Inverted & Flip Vertically)

Invert : Set each color to be (255 the original value):

use RedFilter as a model.

Code:

void redShift(Image& source, int shiftAmount) { for(int i = 0; i < IMG_HEIGHT; i++) { //for each row for(int j = 0; j < IMG_WIDTH; j++) { //for each column //Clamp function makes sure we don't go past 255 and wrap back around to 0 source.data[i][j].red = clamp(source.data[i][j].red + shiftAmount);

} } }

Flip Vertical: use rotate as a model.

Code:

void rotateRight(Image& source) { //First make a temp image to rotate into - makes easier to avoid // overwriting old work as we go. Image temp; for(int i = 0; i < IMG_HEIGHT; i++) { //for each row for(int j = 0; j < IMG_WIDTH; j++) { //for each column //calculate where i, j should rotate to int newRow = j; //new row = old column int newCol = (IMG_WIDTH - 1) - i; //new column = last column - old row

temp.data[newRow][newCol] = source.data[i][j]; } } //Now copy temp image over the top of the source one to replace it source = temp; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Window Functions For Data Analysis And Beyond

Authors: Itzik Ben Gan

2nd Edition

0135861446, 978-0135861448

More Books

Students also viewed these Databases questions