Half a pixel.... ;-)

gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
edited November -1 in Tech Support
Hi, sometimes in the x or y position of actors, it shows a image centre position being something .5 of a pixel, e.g 240.5, etc. My guess is that the position isn't being rounded up or down, maybe?

---------------------------------------------------------------
Spiral Gyro Games

""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Comments

  • design219design219 Member Posts: 2,273
    If you want a 480 x 320 image to be perfectly centered, it need to be positioned at 240.5 x 160.5. Measurements are at the center. Odd.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Thanks, design219; that is odd. I think I can get my head around that, just about! I guess the engine needs these figures to put the 480 x 320 exactly to the perimeter of the screen...um, yet 240.5 x 2 is 481. On second thoughts, still don't get it. Ah well, I'll blindly accept the concept of half a pixel!

    :-)

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Pixels are sort of a made up convention. Photoshop uses them as their smallest unit, but Flash for example, has twentieths of a pixel as their smallest unit.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    is this in GS or photoshop, illustrator etc?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    firemaplegames said:
    Pixels are sort of a made up convention.

    Hi firemaplegames, sorry to doubt this - unless i've misunderstood you - but checking Pixel in Wikipedia, it confirms what I thought of it as: "In digital imaging, a pixel (or picture element[1]) is a single point in a raster image. The pixel is the smallest addressable screen element; it is the smallest unit of picture that can be controlled." In that sense, I don't understand how you can have half a pixel (or twentieth of a pixel in Flash).

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • design219design219 Member Posts: 2,273
    Yeah, I'm going to have to disagree with FMG on pixel. Illustrator is a vector program, so size is really meaningless, whereas Photoshop is a raster program where pixels are all that really mater as far as size.

    As for the .5, think of it like this. If you have a 480 pixel graphic and you count from one side toward the middle, you would count 240 pixels starting from either side. So each half is 240 pixels. GS measures the middle of the graphic, so if you count 240 from one side and 240 from the other side, both counts can't be the middle... it's 240 and 1/2.
  • design219design219 Member Posts: 2,273
    I'm not sure I explained that very clearly, so here is a little graphic I made that might make it easier to visualize.

    image
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    With total respect to FMG, I wonder if he is confusing pixels with points?

    I like your explanation, design219; although 240.5 as a pixel position doesn't work in the "real" sense, that's the way GS does it. I know that in another game-making app I used to use, any graphic position was top left corner, so could be any true pixel position. Of course, problems occurred there as well, when you had to refer to the middle of an uneven number of pixels; in that case, the engine rounded it up to the nearest pixel more, to give it an actual pixel position.

    But middle pixel position is much more useful, I guess. So half a pixel it is!

    :-)

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • design219design219 Member Posts: 2,273
    Ha, you were typing as I posted. See if the little visual makes it clearer.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Yes, it does help (neatly done!), thanks. Though not trying to be clever here, just trying to wrap my (insomniac) brain around it: the position given is still a " virtual" position, would you agree? It's not a real position of a real pixel, like in a real situation e.g in Photoshop, for instance, moving my graphic so its top left corner is at 3.5 pixels in, on a larger image, wouldn't move it 3.5 pixels. Basically, there is no position between pixels...

    Hang on, it's clicked. It's a virtual position, being made up of half of one pixel, and half of the next, for easy of whatever's sake. But "even" in GS, if you put an actor's x position as 35.5, it'd go to 35 or 36. Think that's it.

    :-)

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • design219design219 Member Posts: 2,273
    Yeah, virtual position is one way to think about it. It would be nice if GS allowed you to chance the registration position of artwork. Flash lets you do this easily, and there are situations where setting your orientation point in one of the corners could be very handy... but I'm not complaining, it's just something you have to get used to... or like you say, get your head around.

    Remember to set the graphics settings to "fixed" instead of "stretched" for graphics with odd pixels counts, Like 63 x 64. That will keep them from blurring in an effort to make the centered "half" pixel measure work out.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    design219 said:
    Remember to set the graphics settings to "fixed" instead of "stretched" for graphics with odd pixels counts, Like 63 x 64. That will keep them from blurring in an effort to make the centered "half" pixel measure work out.

    Thanks again for help, design219; and above, that's worth remembering.

    :-)

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Sorry about my earlier post. Yes, the pixel is the smallest element you can address.

    However, many graphics programs allow sub-pixel rendering. Flash has this, as does OpenGL ( which is what Gamesalad uses) and this allows you to place graphics, both raster and vector, at floating point coordinates.

    Fonts use this technique extensively.

    It sort of acts like "dynamic antialiasing". The iPhone uses this everywhere. Although the final image is displayed on a pixel grid, the antialiasing everywhere is the result of all the subpixel data.

    In Flash you are able to position things down to 1/20th of a pixel. I am not sure how small you can position things in OpenGL.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Interesting stuff; thank you firemaplegames!

    :-)

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • SparkyidrSparkyidr Member Posts: 2,033
    I have had a similar prob.

    For example.
    In my ipad app "iTonal HD", when I would sometimes place one of the pads by physically changing the x/y values of the instance, when I hit play or preview, I noticed it would shift sometimes, so I stuck a display text on the pad, and watched it.

    So if I had a pad at say x=150 when I hit play, it would show as 150.5

    I don't remember the exact specifics now as I made the app a while ago.. just remember it being pretty frustrating at the time.
Sign In or Register to comment.