# Question: Program scale. cpp . Scale the original picture to 200% of its size. It can be done by increasing……

In C++

Don't use plagiarized sources. Get Your Custom Essay on
Question: Program scale. cpp . Scale the original picture to 200% of its size. It can be done by increasing……
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!

Program scale. cpp . Scale the original picture to 200% of its size. It can be done by increasing the size of the picture by the factor of 2, and copying each pixel of the input as a small 2×2 square in the output. (We don’t do any interpolation of colors as more advanced scaling procedures would do.) 11 22 11 11 22 22 11 11 22 22 33 33 44 44 33 33 44 44 33 44 Example

the below code show’s the way to scale (only logic)

Code:

#include<iostream>

class RawBitMap

{

public:

RawBitMap():_data(NULL), _width(0),_height(0)

{};

bool Initialise()

{

// Set a basic 2 by 2 bitmap for testing.

//

if(_data != NULL)

delete[] _data;

_width = 2;

_height = 2;

_data = new unsigned char[ GetByteCount() ];

//

_data[0] = 0; // Pixels(0,0) red value

_data[1] = 1; // Pixels(0,0) green value

_data[2] = 2; // Pixels(0,0) blue value

_data[3] = 253; // Pixels(1,0)

_data[4] = 254;

_data[5] = 255;

_data[6] = 253; // Pixels(0,1)

_data[7] = 254;

_data[8] = 255;

_data[9] = 0; // Pixels(1,1)

_data[10] = 1;

_data[11] = 2;

return true;

}

// Perform a basic ‘pixel’ enlarging resample.

bool Resample(int newWidth, int newHeight)

{

if(_data == NULL) return false;

//

// Get a new buuffer to interpolate into

unsigned char* newData = new unsigned char [newWidth * newHeight * 3];

double scaleWidth = (double)newWidth / (double)_width;

double scaleHeight = (double)newHeight / (double)_height;

for(int cy = 0; cy < newHeight; cy++)

{

for(int cx = 0; cx < newWidth; cx++)

{

int pixel = (cy * (newWidth *3)) + (cx*3);

int nearestMatch = (((int)(cy / scaleHeight) * (_width *3)) + ((int)(cx / scaleWidth) *3) );

newData[pixel ] = _data[nearestMatch ];

newData[pixel + 1] = _data[nearestMatch + 1];

newData[pixel + 2] = _data[nearestMatch + 2];

}

}

//

delete[] _data;

_data = newData;

_width = newWidth;

_height = newHeight;

return true;

}

// Show the values of the Bitmap for demo.

void ShowData()

{

std::cout << “Bitmap data:” << std::endl;

std::cout << “============” << std::endl;

std::cout << “Width: ” << _width << std::endl;

std::cout << “Height: ” << _height << std::endl;

std::cout << “Data:” << std::endl;

for(int cy = 0; cy < _height; cy++)

{

for(int cx = 0; cx < _width; cx++)

{

int pixel = (cy * (_width *3)) + (cx*3);

std::cout << “rgb(” << (int)_data[pixel] << “,” << (int)_data[pixel+1] << “,” << (int)_data[pixel+2] << “) “;

}

std::cout << std::endl;

}

std::cout << “_________________________________________________________” << std::endl;

}

// Return the total number of bytes in the Bitmap.

inline int GetByteCount()

{

return (_width * _height * 3);

}

private:

int _width;

int _height;

unsigned char* _data;

};

int main(int argc, char* argv[])

{

RawBitMap bitMap;

bitMap.Initialise();

bitMap.ShowData();

if (!bitMap.Resample(4,4))

std::cout << “Failed to resample bitMap:” << std::endl ;

bitMap.ShowData();

bitMap.Initialise();

if (!bitMap.Resample(3,3))

std::cout << “Failed to resample bitMap:” << std::endl ;

bitMap.ShowData();

return 0;

}

Order NOW For a 10% Discount!
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.