SlideShare a Scribd company logo
1 of 6
Download to read offline
The code in image3.cpp has the error as shown above, could you help me fix them. Thank you.
image3.cpp
#include
#include
#include "image3.hpp"
using namespace std;
/*
ERROR CODES:
-1 : Malloc function not working properly.
-2 : Out Of Scope Pixel.
-3 : File that you are trying to open cannot be opened due to some reason.
*/
/* Constructs an image of 0x0 pixels. */
Image::Image() {
cols=0;
rows=0;
pixels=NULL;
}
/* Frees all memory allocated for img */
Image::~Image() {
cols=0;
rows=0;
delete pixels;
}
/* Changes the size of an image, allocating memory as necessary, and setting all pixels to
fillcolor.
Returns 0 on success, or a non-zero error code.*/
int Image::resize(unsigned int width, unsigned int height, uint8_t fillcolor) {
/*Width of the image is stored in columns.
Height of the image is stored in rows.*/
cols=width;
rows=height;
pixels=(uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
}
for(int i=0; i=cols || y>=rows) {
return -2;
} else {
pixels[x][y]=color;
return 0;
}
}
/* Gets the color of the pixel at (x,y) and stores at the address pointed to by colorp.
Returns 0 on success, else a non-zero error code. */
int Image::get_pixel( unsigned int x, unsigned int y, uint8_t* colorp ) {
if(x>=cols || y>=rows) {
return -2;
} else {
*colorp=pixels[x][y];
return 0;
}
}
/* Saves the image in the file filename. In a format that can be loaded by load().
Returns 0 on success, else a non-zero error code. */
int Image::save(const char* filename) {
ofstream OutputFile(filename);
if(OutputFile.is_open()) {
OutputFile<>input;
if(!ColsAssignment) {
cols=input;
ColsAssignment = true;
} else if(!RowsAssignment) {
rows=input;
RowsAssignment = true;
} else {
if(!PixelsDeclaration) {
pixels = (uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
}
for(int i=0; i // for uint8_t
class Image {
public:
unsigned int cols;
unsigned int rows;
uint8_t** pixels;
/* Constructs an image of 0x0 pixels. */
Image();
/* Frees all memory allocated for img */
~Image();
/* Changes the size of an image, allocating memory as necessary, and
setting all pixels to fillcolor. Returns 0 on success, or a
non-zero error code.*/
int resize( unsigned int width, unsigned int height, uint8_t fillcolor );
/* Sets the color of the pixel at (x,y) to color. Returns 0 on
success, else a non-zero error code. If (x,y) is not a valid
pixel, the call fails and the image does not change.*/
int set_pixel( unsigned int x, unsigned int y, uint8_t color );
/* Gets the color of the pixel at (x,y) and stores at the address
pointed to by colorp. Returns 0 on success, else a non-zero error
code. */
int get_pixel( unsigned int x, unsigned int y, uint8_t* colorp );
/* Saves the image in the file filename. In a format that can be
loaded by load(). Returns 0 on success, else a non-zero error
code. */
int save( const char* filename );
/* Load the an image from the file filename, replacing the current
image size and data. The file is in a format that was saved by
save(). Returns 0 success, else a non-zero error code . */
int load( const char* filename );
}; Make dout cp LAB/image 3.hpp cp LAB/test 3.cpp cp REPO/image 3.cpp g++ -Wall -o t3
test 3.cpp image3.cpp Make stderr: test 3.cpp: In function a€ int main()a€"": test3.cpp 198:21:
warning comparison between signed and unsigned integer expressions [-Wsign-compare]
test3.cpp 199:23: warning comparison between signed and unsigned intege r expressions I-
Wsign-compare] test3.cpp 222:21: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare] image3.cpp: In member function int Image: resize (unsigned int
unsigned int uint8 t)a€"": image3.cpp: 38:20: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare image3.cpp:43:24: warning: comparison between
signed and unsigned integer expressions I-Wsign-compare] image3.cpp: In member function int
Image save (const char*) a€ image3.cpp:78:24: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare image3.cpp:79:28: warning: comparison between
signed and unsigned integer expressions [-Wsign-compare] image3.cpp: In member function int
Image: :load (const char*)€": image3.cpp 118:36: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare] image3.cpp: 124:28: warning: name lookup of
ia€" changed lenabled by default] image 3.cpp: 103:13: warning matches this i€T under old
rules lenabled by default] de image 3.cpp: 118:29: warning image3 .cpp: 103:22: warning:
unused variable a€ ka€" [-Wunused-variable /tmp/ccfZ2udV.o: In function main' image3 .cpp:
(.text+0x7a8) multiple definition of main /tmp/ccpXXxQE.o:test3.cpp: (.text+0x0) first defined
here collect2: ld returned 1 exit status make [t3] Error 1 Build failed
Solution
There is multiple Definition of main () { } , Empty implementation in image3.cpp
One in test3.cpp and the other in image3.cpp . Since main () of image3.cpp is empty remove that
. I have pasted the same code by removing int main () { }
#include
#include
#include "image3.hpp"
using namespace std;
/*
ERROR CODES:
-1 : Malloc function not working properly.
-2 : Out Of Scope Pixel.
-3 : File that you are trying to open cannot be opened due to some reason.
*/
/* Constructs an image of 0x0 pixels. */
Image::Image() {
cols=0;
rows=0;
pixels=NULL;
}
/* Frees all memory allocated for img */
Image::~Image() {
cols=0;
rows=0;
delete pixels;
}
/* Changes the size of an image, allocating memory as necessary, and setting all pixels to
fillcolor.
Returns 0 on success, or a non-zero error code.*/
int Image::resize(unsigned int width, unsigned int height, uint8_t fillcolor) {
/*Width of the image is stored in columns.
Height of the image is stored in rows.*/
cols=width;
rows=height;
pixels=(uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
}
for(int i=0; i=cols || y>=rows) {
return -2;
} else {
pixels[x][y]=color;
return 0;
}
}
/* Gets the color of the pixel at (x,y) and stores at the address pointed to by colorp.
Returns 0 on success, else a non-zero error code. */
int Image::get_pixel( unsigned int x, unsigned int y, uint8_t* colorp ) {
if(x>=cols || y>=rows) {
return -2;
} else {
*colorp=pixels[x][y];
return 0;
}
}
/* Saves the image in the file filename. In a format that can be loaded by load().
Returns 0 on success, else a non-zero error code. */
int Image::save(const char* filename) {
ofstream OutputFile(filename);
if(OutputFile.is_open()) {
OutputFile<>input;
if(!ColsAssignment) {
cols=input;
ColsAssignment = true;
} else if(!RowsAssignment) {
rows=input;
RowsAssignment = true;
} else {
if(!PixelsDeclaration) {
pixels = (uint8_t**)malloc(sizeof(uint8_t*)*cols);
if(pixels==NULL) {
return -1;
}
for(int i=0; i

More Related Content

Similar to The code in image3.cpp has the error as shown above, could you help .pdf

Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlabAman Gupta
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray EnginePVS-Studio
 
Gsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comGsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comrobertleew18
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlabAnkur Tyagi
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicssnelkoli
 
A graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationA graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationgraphitech
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfUmarMustafa13
 
Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLABMohsin Siddique
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)JAINAM KAPADIYA
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.comStokesCope20
 
Displaying information within a window.68
Displaying information within a window.68Displaying information within a window.68
Displaying information within a window.68myrajendra
 
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docxmercysuttle
 
Using the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfUsing the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfacteleshoppe
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.comHarrisGeorg21
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimizationveeracynixit
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimizationveeracynixit
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimizationveeracynixit
 

Similar to The code in image3.cpp has the error as shown above, could you help .pdf (20)

Image processing with matlab
Image processing with matlabImage processing with matlab
Image processing with matlab
 
Dip 1
Dip 1Dip 1
Dip 1
 
Anomalies in X-Ray Engine
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray Engine
 
Dip 2
Dip 2Dip 2
Dip 2
 
Gsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.comGsp 215 Enhance teaching-snaptutorial.com
Gsp 215 Enhance teaching-snaptutorial.com
 
Image processing basics using matlab
Image processing basics using matlabImage processing basics using matlab
Image processing basics using matlab
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
A graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolationA graphic library and an application for simple curve manipolation
A graphic library and an application for simple curve manipolation
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
 
Basics of image processing using MATLAB
Basics of image processing using MATLABBasics of image processing using MATLAB
Basics of image processing using MATLAB
 
COMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptxCOMP340 TOPIC 4 THREE.JS.pptx
COMP340 TOPIC 4 THREE.JS.pptx
 
Computer graphics practical(jainam)
Computer graphics practical(jainam)Computer graphics practical(jainam)
Computer graphics practical(jainam)
 
Gsp 215 Believe Possibilities / snaptutorial.com
Gsp 215  Believe Possibilities / snaptutorial.comGsp 215  Believe Possibilities / snaptutorial.com
Gsp 215 Believe Possibilities / snaptutorial.com
 
Displaying information within a window.68
Displaying information within a window.68Displaying information within a window.68
Displaying information within a window.68
 
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx1 of 6  LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
1 of 6 LAB 5 IMAGE FILTERING ECE180 Introduction to.docx
 
Using the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfUsing the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdf
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.com
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 

More from fatoryoutlets

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdffatoryoutlets
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdffatoryoutlets
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdffatoryoutlets
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdffatoryoutlets
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdffatoryoutlets
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdffatoryoutlets
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdffatoryoutlets
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdffatoryoutlets
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdffatoryoutlets
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdffatoryoutlets
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdffatoryoutlets
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdffatoryoutlets
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdffatoryoutlets
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdffatoryoutlets
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdffatoryoutlets
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdffatoryoutlets
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdffatoryoutlets
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdffatoryoutlets
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdffatoryoutlets
 
If law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdfIf law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdffatoryoutlets
 

More from fatoryoutlets (20)

Write an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdfWrite an informal paper that is exactly 3 pages long not counting th.pdf
Write an informal paper that is exactly 3 pages long not counting th.pdf
 
Write a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdfWrite a C program to find factorial of an integer n, where the user .pdf
Write a C program to find factorial of an integer n, where the user .pdf
 
When was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdfWhen was the black body mutation in drosophila melanogaster discover.pdf
When was the black body mutation in drosophila melanogaster discover.pdf
 
What is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdfWhat is it that consumer researchers try to find among varying cultu.pdf
What is it that consumer researchers try to find among varying cultu.pdf
 
What are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdfWhat are pros and cons of Symantec endpoint security softwareSo.pdf
What are pros and cons of Symantec endpoint security softwareSo.pdf
 
All of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdfAll of the following describe the International Accounting Standard .pdf
All of the following describe the International Accounting Standard .pdf
 
The right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdfThe right and left sternocleidomastoid muscles of humans originate o.pdf
The right and left sternocleidomastoid muscles of humans originate o.pdf
 
the ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdfthe ability of the cardiac muscle cells to fire on their own is .pdf
the ability of the cardiac muscle cells to fire on their own is .pdf
 
Template LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdfTemplate LinkedList;I am using templates to make some linkedLists.pdf
Template LinkedList;I am using templates to make some linkedLists.pdf
 
Surface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdfSurface water entering the North Atlantic may have a temperature of .pdf
Surface water entering the North Atlantic may have a temperature of .pdf
 
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdfSuppose the rate of plant growth on Isle Royale supported an equilib.pdf
Suppose the rate of plant growth on Isle Royale supported an equilib.pdf
 
Q1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdfQ1. public void operationZ() throws StackUnderflowException {   .pdf
Q1. public void operationZ() throws StackUnderflowException {   .pdf
 
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdfPrint Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
Print Calculator Question 18 of 20 Sapling Learning Map do ment of Lu.pdf
 
Part A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdfPart A 1. Solid product forms during the addition of the bleach solu.pdf
Part A 1. Solid product forms during the addition of the bleach solu.pdf
 
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdfOnly 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
Only 15 of the carbon-14 in a wooden bowl remains. How old is the b.pdf
 
Note Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdfNote Use Java Write a web server that is capable of processing only.pdf
Note Use Java Write a web server that is capable of processing only.pdf
 
Negotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdfNegotiations are not usually faster in Deal focused cultures than re.pdf
Negotiations are not usually faster in Deal focused cultures than re.pdf
 
9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf9. The tort of assault and the tort of battery A) can occur independe.pdf
9. The tort of assault and the tort of battery A) can occur independe.pdf
 
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdfJj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
Jj_numjnamecityj1SorterParisj2PunchRomej3Reade.pdf
 
If law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdfIf law enforcement fails to give the defendant their Miranda rights,.pdf
If law enforcement fails to give the defendant their Miranda rights,.pdf
 

Recently uploaded

Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 

Recently uploaded (20)

Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

The code in image3.cpp has the error as shown above, could you help .pdf

  • 1. The code in image3.cpp has the error as shown above, could you help me fix them. Thank you. image3.cpp #include #include #include "image3.hpp" using namespace std; /* ERROR CODES: -1 : Malloc function not working properly. -2 : Out Of Scope Pixel. -3 : File that you are trying to open cannot be opened due to some reason. */ /* Constructs an image of 0x0 pixels. */ Image::Image() { cols=0; rows=0; pixels=NULL; } /* Frees all memory allocated for img */ Image::~Image() { cols=0; rows=0; delete pixels; } /* Changes the size of an image, allocating memory as necessary, and setting all pixels to fillcolor. Returns 0 on success, or a non-zero error code.*/ int Image::resize(unsigned int width, unsigned int height, uint8_t fillcolor) { /*Width of the image is stored in columns. Height of the image is stored in rows.*/ cols=width; rows=height; pixels=(uint8_t**)malloc(sizeof(uint8_t*)*cols); if(pixels==NULL) { return -1;
  • 2. } for(int i=0; i=cols || y>=rows) { return -2; } else { pixels[x][y]=color; return 0; } } /* Gets the color of the pixel at (x,y) and stores at the address pointed to by colorp. Returns 0 on success, else a non-zero error code. */ int Image::get_pixel( unsigned int x, unsigned int y, uint8_t* colorp ) { if(x>=cols || y>=rows) { return -2; } else { *colorp=pixels[x][y]; return 0; } } /* Saves the image in the file filename. In a format that can be loaded by load(). Returns 0 on success, else a non-zero error code. */ int Image::save(const char* filename) { ofstream OutputFile(filename); if(OutputFile.is_open()) { OutputFile<>input; if(!ColsAssignment) { cols=input; ColsAssignment = true; } else if(!RowsAssignment) { rows=input; RowsAssignment = true; } else { if(!PixelsDeclaration) { pixels = (uint8_t**)malloc(sizeof(uint8_t*)*cols); if(pixels==NULL) { return -1; }
  • 3. for(int i=0; i // for uint8_t class Image { public: unsigned int cols; unsigned int rows; uint8_t** pixels; /* Constructs an image of 0x0 pixels. */ Image(); /* Frees all memory allocated for img */ ~Image(); /* Changes the size of an image, allocating memory as necessary, and setting all pixels to fillcolor. Returns 0 on success, or a non-zero error code.*/ int resize( unsigned int width, unsigned int height, uint8_t fillcolor ); /* Sets the color of the pixel at (x,y) to color. Returns 0 on success, else a non-zero error code. If (x,y) is not a valid pixel, the call fails and the image does not change.*/ int set_pixel( unsigned int x, unsigned int y, uint8_t color ); /* Gets the color of the pixel at (x,y) and stores at the address pointed to by colorp. Returns 0 on success, else a non-zero error code. */ int get_pixel( unsigned int x, unsigned int y, uint8_t* colorp ); /* Saves the image in the file filename. In a format that can be loaded by load(). Returns 0 on success, else a non-zero error code. */ int save( const char* filename ); /* Load the an image from the file filename, replacing the current image size and data. The file is in a format that was saved by save(). Returns 0 success, else a non-zero error code . */
  • 4. int load( const char* filename ); }; Make dout cp LAB/image 3.hpp cp LAB/test 3.cpp cp REPO/image 3.cpp g++ -Wall -o t3 test 3.cpp image3.cpp Make stderr: test 3.cpp: In function a€ int main()a€"": test3.cpp 198:21: warning comparison between signed and unsigned integer expressions [-Wsign-compare] test3.cpp 199:23: warning comparison between signed and unsigned intege r expressions I- Wsign-compare] test3.cpp 222:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] image3.cpp: In member function int Image: resize (unsigned int unsigned int uint8 t)a€"": image3.cpp: 38:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare image3.cpp:43:24: warning: comparison between signed and unsigned integer expressions I-Wsign-compare] image3.cpp: In member function int Image save (const char*) a€ image3.cpp:78:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare image3.cpp:79:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] image3.cpp: In member function int Image: :load (const char*)€": image3.cpp 118:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] image3.cpp: 124:28: warning: name lookup of ia€" changed lenabled by default] image 3.cpp: 103:13: warning matches this i€T under old rules lenabled by default] de image 3.cpp: 118:29: warning image3 .cpp: 103:22: warning: unused variable a€ ka€" [-Wunused-variable /tmp/ccfZ2udV.o: In function main' image3 .cpp: (.text+0x7a8) multiple definition of main /tmp/ccpXXxQE.o:test3.cpp: (.text+0x0) first defined here collect2: ld returned 1 exit status make [t3] Error 1 Build failed Solution There is multiple Definition of main () { } , Empty implementation in image3.cpp One in test3.cpp and the other in image3.cpp . Since main () of image3.cpp is empty remove that . I have pasted the same code by removing int main () { } #include #include #include "image3.hpp" using namespace std; /* ERROR CODES: -1 : Malloc function not working properly. -2 : Out Of Scope Pixel. -3 : File that you are trying to open cannot be opened due to some reason. */
  • 5. /* Constructs an image of 0x0 pixels. */ Image::Image() { cols=0; rows=0; pixels=NULL; } /* Frees all memory allocated for img */ Image::~Image() { cols=0; rows=0; delete pixels; } /* Changes the size of an image, allocating memory as necessary, and setting all pixels to fillcolor. Returns 0 on success, or a non-zero error code.*/ int Image::resize(unsigned int width, unsigned int height, uint8_t fillcolor) { /*Width of the image is stored in columns. Height of the image is stored in rows.*/ cols=width; rows=height; pixels=(uint8_t**)malloc(sizeof(uint8_t*)*cols); if(pixels==NULL) { return -1; } for(int i=0; i=cols || y>=rows) { return -2; } else { pixels[x][y]=color; return 0; } } /* Gets the color of the pixel at (x,y) and stores at the address pointed to by colorp. Returns 0 on success, else a non-zero error code. */ int Image::get_pixel( unsigned int x, unsigned int y, uint8_t* colorp ) { if(x>=cols || y>=rows) { return -2;
  • 6. } else { *colorp=pixels[x][y]; return 0; } } /* Saves the image in the file filename. In a format that can be loaded by load(). Returns 0 on success, else a non-zero error code. */ int Image::save(const char* filename) { ofstream OutputFile(filename); if(OutputFile.is_open()) { OutputFile<>input; if(!ColsAssignment) { cols=input; ColsAssignment = true; } else if(!RowsAssignment) { rows=input; RowsAssignment = true; } else { if(!PixelsDeclaration) { pixels = (uint8_t**)malloc(sizeof(uint8_t*)*cols); if(pixels==NULL) { return -1; } for(int i=0; i