New function BitmapData::getSize ()

4 posts / 0 new
Last post
TheVinn
Offline
Last seen: 2 months 3 weeks ago
Joined: 29 Aug 2009 - 11:31
New function BitmapData::getSize ()

This function is handy when working with several Image::BitmapData objects and writing asserts:

  Point <int> BitmapData::getSize () const
  {
    return Point <int> (width, height);
  }
jules
Offline
Last seen: 42 min 23 sec ago
Joined: 29 Apr 2013 - 18:37
Re: New function BitmapData::getSize ()

I've got a bit of a psychological block about using a Point to hold a size. I've avoided doing so anywhere up to now, and keep thinking that I should probably add a "Size" class specially for that kind of thing. I know that a size is essentially just a point relative to the origin, but it just feels like it should have a different class..

haydxn
Offline
Last seen: 2 hours 43 min ago
Joined: 10 Apr 2005 - 14:46
Re: New function BitmapData::getSize ()

ditto - that's why I frequently lament [to myself, of course] that the Point class wasn't just called Vector2D ;)

xh

TheVinn
Offline
Last seen: 2 months 3 weeks ago
Joined: 29 Aug 2009 - 11:31
Re: New function BitmapData::getSize ()

jules wrote:
I've got a bit of a psychological block about using a Point to hold a size.

Okay, we can just use a rectangle instead:

  Rectangle <int> BitmapData::getBounds () const
  {
    return Rectangle <int> (0, 0, width, height);
  }

If someone wants the size as a point they could use BitmapData::getBounds().getBottomRight().

FYI, this is non critical. I've created a subclass of BitmapData to facilitate the operations on pixels and I put my getSize() in there.