New function BitmapData::getSize ()

Discussion and support for general JUCE issues

New function BitmapData::getSize ()

Postby TheVinn » Tue Aug 07, 2012 3:08 pm

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

Code: Select all
  Point <int> BitmapData::getSize () const
  {
    return Point <int> (width, height);
  }
Open Source: LayerEffects, VFLib, SimpleDJ, DSP Filters, LuaBridge, JUCE, FreeType, TagLib
"This isn't a big project, it shouldn't take long." - Jules
User avatar
TheVinn
JUCE UberWeenie
 
Posts: 2975
Joined: Sat Aug 29, 2009 11:31 am
Location: Marina del Rey, California

Re: New function BitmapData::getSize ()

Postby jules » Tue Aug 07, 2012 3:48 pm

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..
User avatar
jules
Fearless Leader
 
Posts: 17193
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK

Re: New function BitmapData::getSize ()

Postby haydxn » Tue Aug 07, 2012 3:54 pm

ditto - that's why I frequently lament [to myself, of course] that the Point class wasn't just called Vector2D ;)
xh
User avatar
haydxn
JUCE UberWeenie
 
Posts: 1175
Joined: Sun Apr 10, 2005 2:46 pm
Location: Manchester, UK

Re: New function BitmapData::getSize ()

Postby TheVinn » Tue Aug 07, 2012 3:55 pm

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:

Code: Select all
  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.
Open Source: LayerEffects, VFLib, SimpleDJ, DSP Filters, LuaBridge, JUCE, FreeType, TagLib
"This isn't a big project, it shouldn't take long." - Jules
User avatar
TheVinn
JUCE UberWeenie
 
Posts: 2975
Joined: Sat Aug 29, 2009 11:31 am
Location: Marina del Rey, California


Return to General JUCE discussion

Who is online

Users browsing this forum: gekkie100 and 6 guests