VgaGames4

VgaGames4 - image man-pages

[.. upper level ..]

# vg4->image->attr_sum()

Sum two image-copy attributes.

SYNTAX
void vg4->image->attr_sum(struct VG_ImagecopyAttr *iattr_sum, const struct VG_ImagecopyAttr *iattr1, const struct VG_ImagecopyAttr *iattr2)
FUNCTION PARAMETERS

iattr_sum | For returning summed image-copy attributes
iattr1 | Image-copy attributes to be summed
iattr2 | Image-copy attributes to be summed

DESCRIPTION
Sum two image-copy attributes. Use this function if an image has image-copy attributes, e.g. from a sprite, and shall be copied with additional image-copy attributes.
EXAMPLE

    /* copy image of a sprite with reduced brightness onto window */

    struct VG_Sprite *sprt;
    struct VG_Image *imgp;
    struct VG_ImagecopyAttr iattr1, iattr2, iattr_sum;

    /* load sprite, assuming no error */
    sprt = vg4->sprite->load("my.sprite");

    /* set attributes with reduced brightness */
    VG_IMAGECOPY_ATTR_DEFAULT(&iattr1);
    iattr1.pixel.brightness = 50;

    /* get next image of sprite */
    if (vg4->sprite->next(sprt, &imgp, &iattr2) && imgp != NULL) {
      /* sum reduced brightness with attributes from sprite-image */
      vg4->image->attr_sum(&iattr_sum, &iattr1, &iattr2);
      /* copy image onto window with calculated attributes */
      vg4->window->copy(imgp, NULL, &iattr_sum);
    }