bitmap
| shotjase (36) | |||
i have this bitmap file that is defining all its constructors and it is not compliling proply can anyone see any errors..thanksusing namespace std; bitmap::bitmap() { //vector < vector <bool> > g; numrows = 1; numcols = 1; grid.resize(numrows, vector <bool> (numcols,false)); } void bitmap::display() const { for (int r = 0; r < numrows; r++) { for (int c = 0; c < numcols; c++) { if (grid[r][c] == 0) cout << " " ; else cout << "*"; } cout << endl; } } int bitmap::getRows() const { return numrows; } int bitmap::getCols() const { return numcols; } void bitmap::save (string filename) const { ofstream infile(filename.c_str()); if (infile.is_open()) { infile << numrows; infile << numcols; for (int r = 0; r < numrows; r++) { for (int c = 0; c < numcols; c++) { infile << grid[r][c]; } } } else { cout <<"Failed to open file" << cout; } infile.close(); } void bitmap::read (string filename) { ifstream infile; infile.open(filename.c_str()); if (infile.fail()) { cout << "Invalid filename " << endl; } if (infile >> numrows >> numcols) { grid.resize(numrows, vector <bool> (numcols,false)); char ch; for (int r = 0; r < numrows; r++) for (int c = 0; c < numcols; c++) { infile >> ch; grid[r][c] = (ch!= '0'); } } } void bitmap::invert() { for (int r = 0; r < numrows; r++) { for (int c = 0; c < numcols; c++) { if (grid[r][c] = 1) { grid[r][c] = 0; } else{ grid[r][c] = 1; } } } } void bitmap::magnify() { //The image is doubled both vertically and horizontally. } void bitmap::rotate() { //The image is rotated 90 degress clockwise. Note that 4 rotations should return to the original image. } | |||
| shotjase (36) | |||
| sorry 4 posting 2..i thought i cancelled the 1st one | |||
| Grey Wolf (536) | |||
| > it is not compliling proply What errors are you getting? How to put code into your postings: http://www.cplusplus.com/forum/articles/1624/ | |||
| shotjase (36) | |||
| my save function does not proply work i have been told that i have to have a white space between the numebr of rows and the number of cols and the rest of the data but i dont know how 2 do this? | |||
| Grey Wolf (536) | |||
| |||
| shotjase (36) | |||
| thankyou 4 ur help it worked... my invert is not working nothing shows up wen i use it void bitmap::invert() { for (int r = 0; r < numrows; r++) { for (int c = 0; c < numcols; c++) { if (grid[r][c] = 1) { grid[r][c] = 0; } else{ grid[r][c] = 1; } } } } does any one have a clue what could b wrong with it | |||
| shotjase (36) | |||
| wait i jus figured out the answer sorry about that does anyone think they could help me out on the rotate or magnify constructors..thanks | |||
| shotjase (36) | |||
sorry again haha i tryed 2 do this with my codevoid bitmap::invert(){ for (int r = 0; r < numrows; r++) { for (int c = 0; c < numcols; c++) { if (grid[r][c] == 0) cout << "*" ; else cout << " "; } cout << endl; } } but i realized when pressing it 2wice it wouldnt go back 2 original image | |||
| Grey Wolf (536) | |||
| Shotjase, You have been asked on many occasions to read the guidance articles on asking questions and inserting code into your post. You do not seem to give us the common courtesy to attempt to follow these guidelines, so I (for one) regret that I will no long be able to offer you help. | |||
| shotjase (36) | |||
| r u serious....man i tryd 2 do the code writing bit but it dont work 4 me..didnt realize u hadta b a c++ professional programer 2 ask questions on this site...mad help grey wolf | |||
| Grey Wolf (536) | |||
| Shotjase, I am perfectly serious. Just take a look at this thread; to start with the title is meaningless. You then intimate that you have a problem with your code not compiling properly but fail to say what the errors are. When asked you say that save function doesn’t have spaces in it! Well how the hell is anyone meant to figure out that that was your problem? And so on… I’m in no way asking you to be a professional programmer, all I am saying is don’t make it hard work for people to help you. If you carry on asking extremely vague questions, using txt speak, not putting your code in simple code tags etc. people will start to ignore you. If you don’t find this advise helpful then I’m sorry, but for me, that is how it is. | |||
| enixi0s (33) | |||
i may just say that he tried to use the code on the first thread, if you look you can see a litlle grey box like this :shotjase : You are supposed to put you code BETWEEN the tags not after them. And you should also try spelling correctly when posting. Look
Between the Tags code and /code :) | |||
| Zaita (610) | |||
| "r u serious....man i tryd 2 do the code writing bit but it dont work 4 me..didnt realize u hadta b a c++ professional programer 2 ask questions on this site...mad help grey wolf" Err... You'd expect a "Profesional C++ Programmer" to be the lowest level of expertise before you can use a custom [code ] printf("hello world"; [/code ] tag in HTML. =\ Not very re-assuring | |||
This topic is archived - New replies not allowed.
