/**
    \return 1 on success, 0 on failure
    \brief Test a U_BITMAPINFO object.
    \param Bmi  pointer to a U_BITMAPINFO object.
    \param blimit    one byte past the end of the record.
*/
int bitmapinfo_safe(
      const char *Bmi,
      const char *blimit
   ){
   int       ClrUsed;
   if(IS_MEM_UNSAFE(Bmi, offsetof(U_BITMAPINFO,bmiHeader) + sizeof(U_BITMAPINFOHEADER), blimit))return(0);
   ClrUsed = get_real_color_count(Bmi + offsetof(U_BITMAPINFO,bmiHeader));
   if(ClrUsed &&  IS_MEM_UNSAFE(Bmi, offsetof(U_BITMAPINFO,bmiColors) + ClrUsed*sizeof(U_RGBQUAD), blimit))return(0);
   return(1);
}
Ejemplo n.º 2
0
int e2s_get_DIB_params(PU_BITMAPINFO Bmi, const U_RGBQUAD **ct, uint32_t *numCt,
                       uint32_t *width, uint32_t *height, uint32_t *colortype,
                       uint32_t *invert) {
    uint32_t bic;
    /* if biCompression is not U_BI_RGB some or all of the following might not
     * hold real values */
    PU_BITMAPINFOHEADER Bmih = &(Bmi->bmiHeader);
    bic = Bmih->biCompression;
    *width = Bmih->biWidth;
    *colortype = Bmih->biBitCount;
    if (Bmih->biHeight < 0) {
        *height = -Bmih->biHeight;
        *invert = 1;
    } else {
        *height = Bmih->biHeight;
        *invert = 0;
    }
    if (bic == U_BI_RGB) {
        *numCt = get_real_color_count((const char *)Bmih);
        if (numCt) {
            *ct = (PU_RGBQUAD)((char *)Bmi + sizeof(U_BITMAPINFOHEADER));
        } else {
            *ct = NULL;
        }
    } else if (bic ==
               U_BI_BITFIELDS) { /* to date only encountered once, for 32 bit,
                                    from PPT*/
        *numCt = 0;
        *ct = NULL;
        bic = U_BI_RGB; /* there seems to be no difference, at least for the 32
                           bit images */
    } else {
        *numCt = Bmih->biSizeImage;
        *ct = NULL;
    }
    return (bic);
}