Exemplo n.º 1
0
/*
 * @implemented
 */
HPALETTE
APIENTRY
EngCreatePalette(
    ULONG iMode,
    ULONG cColors,
    ULONG *pulColors,
    ULONG flRed,
    ULONG flGreen,
    ULONG flBlue)
{
    PPALETTE ppal;
    HPALETTE hpal;

    ppal = PALETTE_AllocPalette2(iMode, cColors, pulColors, flRed, flGreen, flBlue);
    if (!ppal) return NULL;

    hpal = GDIOBJ_hInsertObject(&ppal->BaseObject, GDI_OBJ_HMGR_PUBLIC);
    if (!hpal)
    {
        DPRINT1("Could not insert palette into handle table.\n");
        GDIOBJ_vFreeObject(&ppal->BaseObject);
        return NULL;
    }

    PALETTE_UnlockPalette(ppal);
    return hpal;
}
Exemplo n.º 2
0
PDC
NTAPI
DC_AllocDcWithHandle()
{
    PDC pdc;

    pdc = (PDC)GDIOBJ_AllocateObject(GDIObjType_DC_TYPE,
                                     sizeof(DC),
                                     BASEFLAG_LOOKASIDE);
    if (!pdc)
    {
        DPRINT1("Could not allocate a DC.\n");
        return NULL;
    }

    if (!GDIOBJ_hInsertObject(&pdc->BaseObject, GDI_OBJ_HMGR_POWNED))
    {
        DPRINT1("Could not insert DC into handle table.\n");
        GDIOBJ_vFreeObject(&pdc->BaseObject);
        return NULL;
    }

    pdc->pdcattr = &pdc->dcattr;

    return pdc;
}
Exemplo n.º 3
0
HPALETTE
FASTCALL
PALETTE_AllocPalette(ULONG Mode,
                     ULONG NumColors,
                     ULONG *Colors,
                     ULONG Red,
                     ULONG Green,
                     ULONG Blue)
{
    PPALETTE ppal;
    HPALETTE hpal;

    ppal = PALETTE_AllocPalette2(Mode, NumColors, Colors, Red, Green, Blue);
    if (!ppal) return NULL;

    hpal = GDIOBJ_hInsertObject(&ppal->BaseObject, GDI_OBJ_HMGR_POWNED);
    if (!hpal)
    {
        DPRINT1("Could not insert palette into handle table.\n");
        GDIOBJ_vFreeObject(&ppal->BaseObject);
        return NULL;
    }

    PALETTE_UnlockPalette(ppal);

    return hpal;
}
Exemplo n.º 4
0
PPALETTE
NTAPI
PALETTE_AllocPalWithHandle(
    _In_ ULONG iMode,
    _In_ ULONG cColors,
    _In_opt_ const PALETTEENTRY* pEntries,
    _In_ FLONG flRed,
    _In_ FLONG flGreen,
    _In_ FLONG flBlue)
{
    PPALETTE ppal;

    /* Allocate the palette without a handle */
    ppal = PALETTE_AllocPalette(iMode, cColors, pEntries, flRed, flGreen, flBlue);
    if (!ppal) return NULL;

    /* Insert the palette into the handle table */
    if (!GDIOBJ_hInsertObject(&ppal->BaseObject, GDI_OBJ_HMGR_POWNED))
    {
        DPRINT1("Could not insert palette into handle table.\n");
        GDIOBJ_vFreeObject(&ppal->BaseObject);
        return NULL;
    }

    return ppal;
}
Exemplo n.º 5
0
HPALETTE
FASTCALL
PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
                               CONST RGBQUAD *Colors)
{
    HPALETTE NewPalette;
    PPALETTE PalGDI;
    UINT i;

    PalGDI = (PPALETTE)GDIOBJ_AllocateObject(GDIObjType_PAL_TYPE,
                                           sizeof(PALETTE),
                                           BASEFLAG_LOOKASIDE);
    if (!PalGDI)
    {
        DPRINT1("Could not allocate a palette.\n");
        return NULL;
    }

    if (!GDIOBJ_hInsertObject(&PalGDI->BaseObject, GDI_OBJ_HMGR_POWNED))
    {
        DPRINT1("Could not insert palette into handle table.\n");
        GDIOBJ_vFreeObject(&PalGDI->BaseObject);
        return NULL;
    }

    NewPalette = PalGDI->BaseObject.hHmgr;

    PalGDI->Self = NewPalette;
    PalGDI->flFlags = PAL_INDEXED;

    PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool,
                                                  sizeof(PALETTEENTRY) * NumColors,
                                                  TAG_PALETTE);
    if (NULL == PalGDI->IndexedColors)
    {
        GDIOBJ_vDeleteObject(&PalGDI->BaseObject);
        return NULL;
    }

    for (i = 0; i < NumColors; i++)
    {
        PalGDI->IndexedColors[i].peRed = Colors[i].rgbRed;
        PalGDI->IndexedColors[i].peGreen = Colors[i].rgbGreen;
        PalGDI->IndexedColors[i].peBlue = Colors[i].rgbBlue;
        PalGDI->IndexedColors[i].peFlags = 0;
    }

    PalGDI->NumColors = NumColors;

    PALETTE_UnlockPalette(PalGDI);

    return NewPalette;
}