ImageGear for C and C++ on Windows v21.0 - Updated
API Reference Guide / Core Component API Reference / Core Component Functions Reference / DIB Functions / IG_DIB_pixel_array_size_get
In This Topic
    IG_DIB_pixel_array_size_get
    In This Topic

    This function returns the number of bytes needed to store an array of pixels.

    Declaration:

     
    Copy Code
    AT_ERRCOUNT ACCUAPI IG_DIB_pixel_array_size_get(
            HIGEAR hIGear,
            AT_DIMENSION length,
            AT_MODE format, 
            LPAT_DIMENSION lpSize 
    );
    

    Arguments:

    Name Type Description
    hIGear HIGEAR HIGEAR handle of image containing pixel data.
    length AT_DIMENSION Number of pixels for which to calculate array size.
    format AT_MODE IG_PIXEL_UNPACKED - All bit depths are unpacked (at least one byte per pixel).
    IG_PIXEL_PACKED - In legacy mode: 1 and 4 bit images are packed (8 or 2 pixels per byte). In new mode: Only 1 bit images are packed (8 pixels per byte).
    lpSize LPAT_DIMENSION Returned array size in bytes.

    Return Value:

    Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.

    Supported Raster Image Formats:

    All pixel formats supported by ImageGear for C and C++.

    Sample:

    Pixel Access

    Example:

     
    Copy Code
    /* Get # of bytes needed to store half a row */
    AT_ERRCOUNT nErrcount;  /* Number of errors on stack */
    HIGEAR hImage;          /* Handle of image */
    AT_DIMENSION w, h;      /* Width and height of image */
    AT_DIMENSION nBytes;    /* Size of pixel array in bytes */
    nErrcount = IG_image_dimensions_get(hImage, &w, &h, NULL);
    nErrcount = IG_DIB_pixel_array_size_get(hImage, w / 2, 
        IG_PIXEL_UNPACKED, &nBytes);
    

    Remarks:

    This can be used to allocate storage for use with pixel access functions. This function is similar to IG_DIB_raster_size_get(), but it lets you specify the number of pixels instead of using the number of pixels in an entire raster.