Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About class CRect & Rect, Width = right - left

It is a problem about C++ and mfc. For example, left = 3, right = 8. Doesn't it mean there are 6 pixel from left to right? Why the width = right - left? If I know a rect which represents the image rect, when I allocate memory for the image data, which one should I use? Width = right-left, or Width = right-left+1? I am a beginner of image process. It really confuses me. Thank you for your help!

like image 737
butterfly Avatar asked May 28 '26 10:05

butterfly


1 Answers

If we are talking about CRect and RECT the documentation is clear.

By convention, the right and bottom edges of the rectangle are normally considered exclusive. In other words, the pixel whose coordinates are ( right, bottom ) lies immediately outside of the rectangle. For example, when RECT is passed to the FillRect function, the rectangle is filled up to, but not including, the right column and bottom row of pixels. This structure is identical to the RECTL structure.

The principles of "inclusive lower bound, exclusive upper bound" is used here to. So the number of elements is always the difference between the boundaries.

like image 174
xMRi Avatar answered Jun 01 '26 09:06

xMRi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!