Thread: Width * Height

  1. #16
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by audinue View Post
    Would it be getArea or getSize?
    If this is an object you are yourself creating, it's up to you to define the semantics. As a suggestion though, getArea and getSize should be two different concepts.

    - getArea should return the geometric area of the image in whatever units you deem necessary. Could be pixels, centimeters, inches.
    - getSize should return the physical size of the image as it is occupied in memory.

    Assuming these semantics are defined, then it becomes trivial for the class user to understand that they can use getArea() to read the location of the last pixel of the image.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #17
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    I tend to agree with the above... and I apologize for not understanding what you were looking for earlier. It was, in fact, the code after the edit that threw me off.

    In my opinion, getSize would intuitively return the size of the object in memory and getArea would return the pixel height by the pixel width... That said... if you were to determine a pointer to the end of the image, then you would use getSize because getArea should not be factoring color depth (as each pixel would likely be more than 8-bit).

    In other words, if you were to have a 24-bit bitmap with the size of 100px by 100px... then I would expect a function called getSize to return 240000b (excluding the image header, of course) and getArea to return 10000px. ... and as Mario said, getArea would more than likely allow a parameter to specify the type of value you want returned.
    Last edited by SlyMaelstrom; 09-01-2009 at 07:06 AM.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  3. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 04:49 PM
  4. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM