Change color in a sprite

Home Forums Monkey 2 Programming Help Change color in a sprite

This topic contains 17 replies, has 6 voices, and was last updated by  ArtemKuchin 2 months, 2 weeks ago.

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #10362

    ArtemKuchin
    Participant

    Thank you for explaning the badk work with image data. This is a mess, but probably there is not better way for now at least.

    I understood that pixmap is the basic object for images and that the thing i need. Image is kinda convinience wrapper.

    As you see i am using pixmap load i the example i did.

    But i dont understand how pmAlpha argument for pixmap.load works.

    If i set it to False i don’t get any alpha at all. So, basically it is pmAlpha=True or no alpha at all.

    Did i get it right?

    #10364

    Mark Sibly
    Keymaster

    Image is a bit more than a convenience wrapper – without it, you can’t ‘draw’ pixmaps so it’s pretty important!

    pmAlpha parameter for Pixmap.Load will leave the loaded pixmap alone if false, but will premultiply pixmap colors by pixmap alpha if true. In either case, pixmap alpha values are not modified.

    So if you just want to load the pixmap as it is stored on disk without modifying colors, set pmAlpha to false (or just leave it off as it defaults to false).

    If you do this but are also planning on creating an image with the pixmap, you should use pixmap.PremultiplyAlpha() at some point *before* creating the image. For example:

    In other words, New Image( pixmap ) always assumes you have premultiplied alpha somehow.

    #10365

    ArtemKuchin
    Participant

    Got it. But what exactly premultiplying alpha does on pixmap? It does not seem to modify pixmap data at all. Since pmAlpha is using DESTINATION RGB to calculate resulting pixel color then it seems like premultiplying alpha is just some kind of flag/parameter  which is used by device rendering part. And it seems to work globaly, not locally for one pixmap.

    At least in all examples i saw the pmAlpha is set for d3d globally.

Viewing 3 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic.