Exemplo n.º 1
0
static void appClearItem(wItem *item)
{
    item->type   = itNone;
    item->x      = 0;
    item->y      = 0;
    item->width  = 0;
    item->height = 0;
    bpFree(&item->Bitmap);
    bpFree(&item->Mask);
    item->fontid = 0;
    item->align  = fntAlignLeft;
    gfree((void **)&item->label);
    item->pwidth    = 0;
    item->pheight   = 0;
    item->numphases = 0;
    item->value     = 0;
    item->message   = evNone;
    item->R = 0;
    item->G = 0;
    item->B = 0;
    gfree((void **)&item->text);
    item->textwidth = 0;
    item->starttime = 0;
    item->last_x    = 0;
    item->pressed   = btnDisabled;
    item->tmp       = 0;
}
Exemplo n.º 2
0
/**
 * @brief Free all memory allocated to an item and set all its pointers to NULL.
 *
 * @param item item to be freed
 */
static void appClearItem(wItem *item)
{
    bpFree(&item->Bitmap);
    bpFree(&item->Mask);
    free(item->label);
    free(item->text);
    memset(item, 0, sizeof(*item));
}
Exemplo n.º 3
0
/**
 * @brief Render a bitmap mask for an image.
 *
 * @param in image to render a bitmap mask from
 * @param out bitmap mask
 *
 * @return 1 (ok) or 0 (error)
 *
 * @note As a side effect, transparent pixels of @a in will be rendered black.
 */
int bpRenderMask(const guiImage *in, guiImage *out)
{
    uint32_t *buf;
    unsigned long x, y;
    unsigned long i = 0, c = 0;
    unsigned char tmp = 0, b = 1;
    int shaped = 0;

    out->Width     = in->Width;
    out->Height    = in->Height;
    out->Bpp       = 1;
    out->ImageSize = ((out->Width + 7) / 8) * out->Height;
    out->Image     = calloc(1, out->ImageSize);

    if (!out->Image) {
        mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] not enough memory: %lu\n", out->ImageSize);
        return 0;
    }

    buf = (uint32_t *)in->Image;

    for (y = 0; y < in->Height; y++) {
        for (x = 0; x < in->Width; x++) {
            if (!IS_TRANSPARENT(buf[i]))
                tmp |= b;
            else {
                buf[i] = 0; // pixel should be black (if transparency isn't supported)
                shaped = 1;
            }

            i++;
            b <<= 1;

            if (b == 0) {
                out->Image[c++] = tmp;
                tmp = 0;
                b   = 1;
            }
        }

        if (b != 1) {
            out->Image[c++] = tmp;
            tmp = 0;
            b   = 1;
        }
    }

    if (!shaped)
        bpFree(out);

    mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] 1 bpp conversion size: %lu\n", out->ImageSize);

    return 1;
}