bitmap

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 9
Reputation: shotjase is an unknown quantity at this point 
Solved Threads: 0
shotjase shotjase is offline Offline
Newbie Poster

bitmap

 
0
  #1
May 6th, 2008
i have here this constructor used 2 display a bitmap
  1. void bitmap::display() const
  2. {
  3. for (int r = 0; r < numrows; r++)
  4. {
  5. for (int c = 0; c < numcols; c++)
  6. {
  7. if (grid[r][c] == 0)
  8. cout << " " ;
  9.  
  10. else cout << "*";
  11. }
  12. cout << endl;
  13.  
  14.  
  15. }
  16.  
  17. }
i have here this invert function which is meant to make the 0's into 1's and the * into " " but it is not working proply can ne1 help me

  1. void bitmap::invert()
  2. {
  3. for (int r = 0; r < numrows; r++)
  4. {
  5. for (int c = 0; c < numcols; c++)
  6. {
  7. if (grid[r][c] = 1)
  8. {
  9. grid[r][c] = 0;
  10. cout << "*";
  11. }
  12. else{
  13. grid[r][c] = 1;
  14. cout << " ";
  15. }
  16. }
  17. }
  18. }
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 334
Reputation: Prabakar is on a distinguished road 
Solved Threads: 29
Prabakar's Avatar
Prabakar Prabakar is offline Offline
Posting Whiz

Re: bitmap

 
0
  #2
May 6th, 2008
Its a simple mistake.
if (grid[r][c] = 1)

= is an assinment operator. == is the relational operator

The code is just fine
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 9
Reputation: shotjase is an unknown quantity at this point 
Solved Threads: 0
shotjase shotjase is offline Offline
Newbie Poster

Re: bitmap

 
0
  #3
May 6th, 2008
i did that but the invert still doesnt work it displays, but the *'s and ' 's are all really far apart
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 334
Reputation: Prabakar is on a distinguished road 
Solved Threads: 29
Prabakar's Avatar
Prabakar Prabakar is offline Offline
Posting Whiz

Re: bitmap

 
0
  #4
May 6th, 2008
I dont have much code to deal with, besides the constructor displays a '*' if mat element is 1 & the invert function does the same, even though it changes the matrix. Upload more code
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: bitmap

 
0
  #5
May 6th, 2008
Why does invert() also display the result?
Shouldn't you just call display() when you're done?

Each function does ONE job properly.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC