Ejemplo n.º 1
0
/*
 * @implemented
 */
HPALETTE APIENTRY
NtGdiCreatePaletteInternal ( IN LPLOGPALETTE pLogPal, IN UINT cEntries )
{
    PPALETTE PalGDI;
    HPALETTE NewPalette;

    pLogPal->palNumEntries = cEntries;
    NewPalette = PALETTE_AllocPalette( PAL_INDEXED,
                                       cEntries,
                                       (PULONG)pLogPal->palPalEntry,
                                       0, 0, 0);

    if (NewPalette == NULL)
    {
        return NULL;
    }

    PalGDI = (PPALETTE) PALETTE_ShareLockPalette(NewPalette);
    if (PalGDI != NULL)
    {
        PALETTE_ValidateFlags(PalGDI->IndexedColors, PalGDI->NumColors);
        PALETTE_ShareUnlockPalette(PalGDI);
    }
    else
    {
        /* FIXME - Handle PalGDI == NULL!!!! */
        DPRINT1("PalGDI is NULL\n");
    }
  return NewPalette;
}
Ejemplo n.º 2
0
UINT APIENTRY
IntAnimatePalette(HPALETTE hPal,
                  UINT StartIndex,
                  UINT NumEntries,
                  CONST PPALETTEENTRY PaletteColors)
{
    UINT ret = 0;

    if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) )
    {
        PPALETTE palPtr;
        UINT pal_entries;
        HDC hDC;
        PDC dc;
        PWND Wnd;
        const PALETTEENTRY *pptr = PaletteColors;

        palPtr = PALETTE_ShareLockPalette(hPal);
        if (!palPtr) return FALSE;

        pal_entries = palPtr->NumColors;
        if (StartIndex >= pal_entries)
        {
            PALETTE_ShareUnlockPalette(palPtr);
            return FALSE;
        }
        if (StartIndex+NumEntries > pal_entries) NumEntries = pal_entries - StartIndex;

        for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++)
        {
            /* According to MSDN, only animate PC_RESERVED colours */
            if (palPtr->IndexedColors[StartIndex].peFlags & PC_RESERVED)
            {
                memcpy( &palPtr->IndexedColors[StartIndex], pptr,
                        sizeof(PALETTEENTRY) );
                ret++;
                PALETTE_ValidateFlags(&palPtr->IndexedColors[StartIndex], 1);
            }
        }

        PALETTE_ShareUnlockPalette(palPtr);

        /* Immediately apply the new palette if current window uses it */
        Wnd = UserGetDesktopWindow();
        hDC =  UserGetWindowDC(Wnd);
        dc = DC_LockDc(hDC);
        if (NULL != dc)
        {
            if (dc->dclevel.hpal == hPal)
            {
                DC_UnlockDc(dc);
                IntGdiRealizePalette(hDC);
            }
            else
                DC_UnlockDc(dc);
        }
        UserReleaseDC(Wnd,hDC, FALSE);
    }
    return ret;
}
Ejemplo n.º 3
0
HPALETTE
NTAPI
GreCreatePaletteInternal(
    IN LPLOGPALETTE pLogPal,
    IN UINT cEntries)
{
    HPALETTE hpal = NULL;
    PPALETTE ppal;

    pLogPal->palNumEntries = cEntries;
    ppal = PALETTE_AllocPalWithHandle(PAL_INDEXED,
                                      cEntries,
                                      pLogPal->palPalEntry,
                                      0, 0, 0);

    if (ppal != NULL)
    {
        PALETTE_ValidateFlags(ppal->IndexedColors, ppal->NumColors);

        hpal = ppal->BaseObject.hHmgr;
        PALETTE_UnlockPalette(ppal);
    }

    return hpal;
}
Ejemplo n.º 4
0
/*
 * @implemented
 */
HPALETTE
APIENTRY
NtGdiCreatePaletteInternal(
    IN LPLOGPALETTE plogpalUser,
    IN UINT cEntries)
{
    HPALETTE hpal = NULL;
    PPALETTE ppal;
    ULONG i, cjSize;

    ppal = PALETTE_AllocPalWithHandle(PAL_INDEXED, cEntries, NULL, 0, 0, 0);
    if (ppal == NULL)
    {
        return NULL;
    }

    cjSize = FIELD_OFFSET(LOGPALETTE, palPalEntry[cEntries]);

    _SEH2_TRY
    {
        ProbeForRead(plogpalUser, cjSize, 1);

        for (i = 0; i < cEntries; i++)
        {
            ppal->IndexedColors[i] = plogpalUser->palPalEntry[i];
        }
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        GDIOBJ_vDeleteObject(&ppal->BaseObject);
        _SEH2_YIELD(return NULL);
    }
    _SEH2_END;

    PALETTE_ValidateFlags(ppal->IndexedColors, cEntries);
    hpal = ppal->BaseObject.hHmgr;
    PALETTE_UnlockPalette(ppal);

    return hpal;
}