本文整理汇总了C++中CreatePalette函数的典型用法代码示例。如果您正苦于以下问题:C++ CreatePalette函数的具体用法?C++ CreatePalette怎么用?C++ CreatePalette使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreatePalette函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: winCreateColormapShadowGDI
Bool
winCreateColormapShadowGDI (ColormapPtr pColormap)
{
LPLOGPALETTE lpPaletteNew = NULL;
DWORD dwEntriesMax;
VisualPtr pVisual;
HPALETTE hpalNew = NULL;
winCmapPriv(pColormap);
/* Get a pointer to the visual that the colormap belongs to */
pVisual = pColormap->pVisual;
/* Get the maximum number of palette entries for this visual */
dwEntriesMax = pVisual->ColormapEntries;
/* Allocate a Windows logical color palette with max entries */
lpPaletteNew = malloc (sizeof (LOGPALETTE)
+ (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
if (lpPaletteNew == NULL)
{
ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
"with %d entries\n",
dwEntriesMax);
return FALSE;
}
/* Zero out the colormap */
ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
+ (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
/* Set the logical palette structure */
lpPaletteNew->palVersion = 0x0300;
lpPaletteNew->palNumEntries = dwEntriesMax;
/* Tell Windows to create the palette */
hpalNew = CreatePalette (lpPaletteNew);
if (hpalNew == NULL)
{
ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
free (lpPaletteNew);
return FALSE;
}
/* Save the Windows logical palette handle in the X colormaps' privates */
pCmapPriv->hPalette = hpalNew;
/* Free the palette initialization memory */
free (lpPaletteNew);
return TRUE;
}
示例2: CSocket
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner):TForm(Owner)
{
char *ptr;
char aux[100];
S1 = new CSocket();
wsprintf(aux, " %s %s", S1->NombreHostLocal, S1->cadenaIP);
PHOST->Caption = aux;
LeyendoFoto = false;
PBinin->Caption = (int)Binin;
TBBinin->Position = (int)Binin;
NumeroFilas = PFilas->Caption.ToInt() / Binin;
NumeroColumnas = PColumnas->Caption.ToInt() / Binin;
PB1->Width = NumeroColumnas + 4;
PB1->Height = NumeroFilas + 4;
X1F = X1 = PX1->Caption.ToInt();
X2F = X2 = PX2->Caption.ToInt();
Y1F = Y1 = PY1->Caption.ToInt();
Y2F = Y2 = PY2->Caption.ToInt();
SysPal.lpal.palVersion = 0x300;
SysPal.lpal.palNumEntries = 256;
for(int c = 0; c < 256; c++)
{
SysPal.dummy[c].peRed = c;
SysPal.dummy[c].peGreen = c;
SysPal.dummy[c].peBlue = c;
SysPal.dummy[c].peFlags = PC_NOCOLLAPSE;
}
BM1 = new Graphics::TBitmap();
BM1->Height = NumeroFilas;
BM1->Width = NumeroColumnas;
BM1->PixelFormat = pf8bit;
BM1->Palette = CreatePalette(&SysPal.lpal);
Filtro = new CRueda(PFiltro, 0, 0, 130, 7, "Filtro", 'z');
//PFiltro->Left = 20;
PFiltro->Width = Filtro->Width;
PFiltro->Height = Filtro->Height;
Filtro->S1 = S1;
Filtro->enviarReset();
Shuter = new CRueda(PShuter, 0, 0, 130, 3, "Shuter", 'y');
//PShuter->Left = 20;
PShuter->Width = Shuter->Width;
PShuter->Height = Shuter->Height;
Shuter->S1 = S1;
Shuter->enviarReset();
}
示例3: RGB
void CHyperLink::Initialize()
{
m_lpLinkText = NULL;
m_lpLinkUrl = NULL;
m_hFont.CreateFont(14,0,0,0,FW_NORMAL,0,0,0,
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,DEFAULT_PITCH | FF_DONTCARE,"Arial");
m_bUnderlineAlways = FALSE;
m_bIsLink = TRUE;
m_bLockInPosition = FALSE;
m_bMultiline = FALSE;
m_crLinkUp = RGB(0,66,118);
m_crLinkHover = RGB(255,0,0);
m_crLinkDown = RGB(200,0,225);
m_crBackGround = ::GetSysColor(COLOR_BTNFACE);
m_crBorder = RGB(0,0,0);
m_nBorderSize = 0;
m_nBorderStyle = PS_SOLID;
m_hReg = NULL;
m_hHand = ::LoadCursor(NULL, MAKEINTRESOURCE(32649));
m_hIconUp = NULL;
m_hIconHover = NULL;
m_hIconDown = NULL;
m_hIconDisabled = NULL;
m_uShowIcon = SI_ICONUP_ON | SI_ICONUP_LEFT | //Default: icons on the left Up/Hover/Down/Disabled
SI_ICONHOVER_ON | SI_ICONHOVER_LEFT |
SI_ICONDOWN_ON | SI_ICONDOWN_LEFT |
SI_ICONDISABLED_ON | SI_ICONDISABLED_LEFT;
m_bAutoGenerateDisabled = FALSE;
m_bAutoGenerated = FALSE;
m_pToolTip = &m_ToolTip;
//Status and Mouse control variables
m_bDisabled = FALSE;
m_bMouseIn = FALSE;
m_bMouseDown = FALSE;
m_bMovingWindow = FALSE;
CreatePalette();
}
示例4: return
/////////////////////////////////////////////////////////////////////////////
//
// Attach is just like the CGdiObject version, except it also creates the
// palette.
//
/////////////////////////////////////////////////////////////////////////////
zBOOL
ZDib::Attach( HGDIOBJ hbm )
{
if ( CBitmap::Attach( hbm ) )
{
if ( GetBitmap( &m_bitmap ) == 0 ) // load BITMAP for speed
return( FALSE );
m_palette.DeleteObject( ); // in case one is already there
return( CreatePalette( m_palette ) ); // create palette
}
return( FALSE );
}
示例5: image_make_bitmap_palette
HPALETTE
image_make_bitmap_palette( Handle img)
{
PDrawable i = ( PDrawable) img;
int j, nColors = i-> palSize;
XLOGPALETTE lp;
HPALETTE r;
RGBColor dest[ 256];
PRGBColor logp = i-> palette;
lp. palVersion = 0x300;
lp. palNumEntries = nColors;
if ( nColors == 0) return nil;
if ( !dsys(img)p256) {
if ( nColors > 256) {
dsys(img)p256 = ( PXLOGPALETTE) malloc( sizeof( XLOGPALETTE));
cm_squeeze_palette( i-> palette, nColors, dest, 256);
nColors = lp. palNumEntries = 256;
logp = dest;
}
for ( j = 0; j < nColors; j++) {
lp. palPalEntry[ j]. peRed = logp[ j]. r;
lp. palPalEntry[ j]. peGreen = logp[ j]. g;
lp. palPalEntry[ j]. peBlue = logp[ j]. b;
lp. palPalEntry[ j]. peFlags = 0;
}
if ( dsys(img)p256) memcpy( dsys(img)p256, &lp, sizeof( XLOGPALETTE));
if ( !( r = CreatePalette(( LOGPALETTE*) &lp))) apiErrRet;
} else {
if ( !( r = CreatePalette(( LOGPALETTE*) dsys(img)p256))) apiErrRet;
}
return r;
}
示例6: set_palette
/* Primitive palette functions */
static int set_palette (UINT8 *pal, int scol, int numcols)
{
int i;
#if 0
HDC hdc;
LOGPALETTE *palette;
PALETTEENTRY *entries;
hdc = GetDC(hwndMain);
if (GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL) <= 8) {
entries = (PALETTEENTRY *)malloc(32 * sizeof(PALETTEENTRY));
for (i = scol; i < numcols; i++) {
entries[i].peRed = pal[i*3 ] << 2;
entries[i].peGreen = pal[i*3 + 1] << 2;
entries[i].peBlue = pal[i*3 + 2] << 2;
entries[i].peFlags = PC_NOCOLLAPSE;
}
palette = malloc(sizeof(*palette) + 32 * sizeof(PALETTEENTRY));
if (palette == NULL) {
OutputDebugString("malloc failed for palette");
return err_Unk;
}
palette->palVersion = 0x300;
palette->palNumEntries = 32;
g_hPalette = CreatePalette(palette);
free(palette);
SetPaletteEntries(g_hPalette, 0, 32, entries);
SelectPalette(hdc, g_hPalette, FALSE);
RealizePalette(hdc);
} else
#endif
for (i = scol; i < numcols; i ++) {
g_screen.binfo->bmiColors[i].rgbRed = (pal[i*3 ]) << 2;
g_screen.binfo->bmiColors[i].rgbGreen= (pal[i*3 + 1]) << 2;
g_screen.binfo->bmiColors[i].rgbBlue = (pal[i*3 + 2]) << 2;
g_screen.binfo->bmiColors[i].rgbReserved = 0;
}
ReleaseDC(hwndMain, hdc);
return err_OK;
}
示例7: GetDC
HPALETTE FAR CJpegFile::GetSystemPalette(void)
{
HDC hDC; // handle to a DC
static HPALETTE hPal = NULL; // handle to a palette
HANDLE hLogPal; // handle to a logical palette
LPLOGPALETTE lpLogPal; // pointer to a logical palette
int nColors; // number of colors
/* Find out how many palette entries we want. */
hDC = GetDC(NULL);
if (!hDC)
return NULL;
nColors = PalEntriesOnDevice(hDC); // Number of palette entries
if(nColors == 0) return NULL;
/* Allocate room for the palette and lock it. */
hLogPal = GlobalAlloc(GHND, sizeof(LOGPALETTE) + nColors * sizeof(
PALETTEENTRY));
/* if we didn't get a logical palette, return NULL */
if (!hLogPal)
return NULL;
/* get a pointer to the logical palette */
lpLogPal = (LPLOGPALETTE)GlobalLock(hLogPal);
/* set some important fields */
lpLogPal->palVersion = PALVERSION;
lpLogPal->palNumEntries = nColors;
/* Copy the current system palette into our logical palette */
GetSystemPaletteEntries(hDC, 0, nColors,
(LPPALETTEENTRY)(lpLogPal->palPalEntry));
/* Go ahead and create the palette. Once it's created,
* we no longer need the LOGPALETTE, so free it.
*/
hPal = CreatePalette(lpLogPal);
/* clean up */
GlobalUnlock(hLogPal);
GlobalFree(hLogPal);
ReleaseDC(NULL, hDC);
return hPal;
}
示例8: MakeDIBPalette
/*
* Given a BITMAPINFOHEADER, create a palette based on the color table.
*
* Returns the handle of a palette, or zero if something went wrong.
*/
static HPALETTE PASCAL NEAR MakeDIBPalette(LPBITMAPINFOHEADER lpInfo)
{
PLOGPALETTE npPal;
RGBQUAD FAR *lpRGB;
HPALETTE hLogPal;
DWORD i;
/*
* since biClrUsed field was filled during the loading of the DIB,
* we know it contains the number of colors in the color table.
*/
if (lpInfo->biClrUsed)
{
npPal = (PLOGPALETTE)LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) +
(WORD)lpInfo->biClrUsed * sizeof(PALETTEENTRY));
if (!npPal)
return (FALSE);
npPal->palVersion = 0x300;
npPal->palNumEntries = (WORD)lpInfo->biClrUsed;
/* get pointer to the color table */
lpRGB = (RGBQUAD FAR *)((LPSTR)lpInfo + lpInfo->biSize);
/* copy colors from the color table to the LogPalette structure */
for (i = 0; i < lpInfo->biClrUsed; i++, lpRGB++)
{
npPal->palPalEntry[i].peRed = lpRGB->rgbRed;
npPal->palPalEntry[i].peGreen = lpRGB->rgbGreen;
npPal->palPalEntry[i].peBlue = lpRGB->rgbBlue;
npPal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
}
hLogPal = CreatePalette((LPLOGPALETTE)npPal);
LocalFree((HANDLE)npPal);
return (hLogPal);
}
/*
* 24-bit DIB with no color table. return default palette. Another
* option would be to create a 256 color "rainbow" palette to provide
* some good color choices.
*/
else
{
return (GetStockObject(DEFAULT_PALETTE));
}
}
示例9: CreateRoutine
HPALETTE CreateRoutine (HWND hwnd)
{
HPALETTE hPalette ;
lp.palVersion = 0x0300 ;
lp.palNumEntries = 1 ;
lp.palPalEntry[0].peRed = 255 ;
lp.palPalEntry[0].peGreen = 255 ;
lp.palPalEntry[0].peBlue = 255 ;
lp.palPalEntry[0].peFlags = PC_RESERVED ;
hPalette = CreatePalette (&lp) ;
SetTimer (hwnd, ID_TIMER, 50, NULL) ;
return hPalette ;
}
示例10: GetSystemPalette
HPALETTE GetSystemPalette(void)
{
HDC hDC; // handle to a DC
HPALETTE hPal = NULL; // handle to a palette
HANDLE hLogPal; // handle to a logical palette
LPLOGPALETTE lpLogPal; // pointer to a logical palette
int i, nColors; // loop index, number of colors
/* Find out how many palette entries we want. */
hDC = GetDC(NULL);
if (!hDC)
return NULL;
nColors = PalEntriesOnDevice(hDC);
ReleaseDC(NULL, hDC);
/* Allocate room for the palette and lock it. */
hLogPal = GlobalAlloc(GHND, sizeof(LOGPALETTE) + nColors * sizeof(
PALETTEENTRY));
/* if we didn't get a logical palette, return NULL */
if (!hLogPal)
return NULL;
/* get a pointer to the logical palette */
lpLogPal = (LPLOGPALETTE)GlobalLock(hLogPal);
/* set some important fields */
lpLogPal->palVersion = PALVERSION;
lpLogPal->palNumEntries = nColors;
for (i = 0; i < nColors; i++)
{
lpLogPal->palPalEntry[i].peBlue = 0;
*((LPWORD)(&lpLogPal->palPalEntry[i].peRed)) = i;
lpLogPal->palPalEntry[i].peFlags = PC_EXPLICIT;
}
/* Go ahead and create the palette. Once it's created,
* we no longer need the LOGPALETTE, so free it.
*/
hPal = CreatePalette(lpLogPal);
/* clean up */
GlobalUnlock(hLogPal);
GlobalFree(hLogPal);
return hPal;
}
示例11: setupPalette
void
setupPalette(HDC hDC)
{
int pixelFormat = GetPixelFormat(hDC);
PIXELFORMATDESCRIPTOR pfd;
LOGPALETTE* pPal;
int paletteSize;
DescribePixelFormat(hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.dwFlags & PFD_NEED_PALETTE) {
paletteSize = 1 << pfd.cColorBits;
} else {
return;
}
pPal = (LOGPALETTE*)
malloc(sizeof(LOGPALETTE) + paletteSize * sizeof(PALETTEENTRY));
pPal->palVersion = 0x300;
pPal->palNumEntries = paletteSize;
/* build a simple RGB color palette */
{
int redMask = (1 << pfd.cRedBits) - 1;
int greenMask = (1 << pfd.cGreenBits) - 1;
int blueMask = (1 << pfd.cBlueBits) - 1;
int i;
for (i=0; i<paletteSize; ++i) {
pPal->palPalEntry[i].peRed =
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
pPal->palPalEntry[i].peGreen =
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
pPal->palPalEntry[i].peBlue =
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
pPal->palPalEntry[i].peFlags = 0;
}
}
hPalette = CreatePalette(pPal);
free(pPal);
if (hPalette) {
SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC);
}
}
示例12: createRGBPalette
BOOL createRGBPalette(HDC hDC)
{
PIXELFORMATDESCRIPTOR pfd;
LOGPALETTE* pPal;
HPALETTE hPal;
int i,j,n;
/* Check to see if we need a palette */
n = GetPixelFormat(hDC);
DescribePixelFormat(hDC, n, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (!(pfd.dwFlags & PFD_NEED_PALETTE)) return FALSE ;
/* Allocate a log pal and fill it with the color table info */
pPal = (LOGPALETTE*) malloc(sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY));
pPal->palVersion = 0x300; /* Windows 3.0 */
pPal->palNumEntries = 256; /* table size */
/*/ Create palette */
n = 1 << pfd.cColorBits;
for (i=0; i<n; i++)
{
pPal->palPalEntry[i].peRed =
ComponentFromIndex(i, pfd.cRedBits, pfd.cRedShift);
pPal->palPalEntry[i].peGreen =
ComponentFromIndex(i, pfd.cGreenBits, pfd.cGreenShift);
pPal->palPalEntry[i].peBlue =
ComponentFromIndex(i, pfd.cBlueBits, pfd.cBlueShift);
pPal->palPalEntry[i].peFlags = 0;
}
if ((pfd.cColorBits == 8) &&
(pfd.cRedBits == 3) && (pfd.cRedShift == 0) &&
(pfd.cGreenBits == 3) && (pfd.cGreenShift == 3) &&
(pfd.cBlueBits == 2) && (pfd.cBlueShift == 6))
{
for (j = 1 ; j <= 12 ; j++)
pPal->palPalEntry[m_defaultOverride[j]] = m_defaultPalEntry[j];
}
hPal = CreatePalette(pPal);
SelectPalette(hDC,hPal,FALSE);
return TRUE;
}
示例13: CreateCIPalette
static HPALETTE CreateCIPalette( HDC Dc )
{
LOGPALETTE *LogicalPalette;
HPALETTE StockPalette;
UINT PaletteSize, StockPaletteSize, EntriesToCopy;
if ( (Dc != NULL) && (NULL == tkhpalette) )
{
PaletteSize = 256; //(Pfd.cColorBits >= 8) ? 256 : (1 << Pfd.cColorBits);
LogicalPalette = AllocateZeroedMemory( sizeof(LOGPALETTE) +
(PaletteSize * sizeof(PALETTEENTRY)) );
if ( NULL != LogicalPalette )
{
LogicalPalette->palVersion = 0x300;
LogicalPalette->palNumEntries = PaletteSize;
StockPalette = GetStockObject(DEFAULT_PALETTE);
StockPaletteSize = GetPaletteEntries( StockPalette, 0, 0, NULL );
/*
* start by copying default palette into new one
*/
EntriesToCopy = StockPaletteSize < PaletteSize ?
StockPaletteSize : PaletteSize;
GetPaletteEntries( StockPalette, 0, EntriesToCopy,
LogicalPalette->palPalEntry );
/*
* If we are taking possession of the system colors,
* must guarantee that 0 and 255 are black and white
* (respectively).
*/
tkhpalette = CreatePalette(LogicalPalette);
FreeMemory(LogicalPalette);
RealizePaletteNow( Dc, tkhpalette);
}
}
return( tkhpalette );
}
示例14: GetPixelFormat
void OGLWindow::setupPalette()
{
int pixelFormat = GetPixelFormat(hDC ());
PIXELFORMATDESCRIPTOR pfd;
LOGPALETTE* pPal;
int paletteSize;
int redMask, greenMask, blueMask;
int i;
DescribePixelFormat(hDC (), pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.dwFlags & PFD_NEED_PALETTE)
paletteSize = 1 << pfd.cColorBits;
else
return;
pPal = (LOGPALETTE*)LocalAlloc(LPTR, sizeof(LOGPALETTE) + paletteSize * sizeof(PALETTEENTRY));
pPal->palVersion = 0x300;
pPal->palNumEntries = (short)paletteSize;
// build a simple RGB color palette
redMask = (1 << pfd.cRedBits) - 1;
greenMask = (1 << pfd.cGreenBits) - 1;
blueMask = (1 << pfd.cBlueBits) - 1;
for (i=0; i<paletteSize; ++i)
{ pPal->palPalEntry[i].peRed = (BYTE)(
(((i >> pfd.cRedShift) & redMask) * 255) / redMask);
pPal->palPalEntry[i].peGreen = (BYTE)(
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask);
pPal->palPalEntry[i].peBlue = (BYTE)(
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask);
pPal->palPalEntry[i].peFlags = 0;
}
hPalette_ = CreatePalette(pPal);
LocalFree(pPal);
if (hPalette_)
{
DeleteObject(SelectPalette(hDC (), hPalette_, FALSE));
RealizePalette(hDC ());
}
}
示例15: CreatePalette
void __fastcall TForm1::RBK400Click(TObject *Sender)
{
if(RBK400->Checked == true)
{
RBK1600->Checked == false;
NumeroColumnas = 768;
NumeroFilas = 512;
}
else
{
RBK1600->Checked == true;
NumeroColumnas = 768*2;
NumeroFilas = 512*2;
}
PFilas->Caption = NumeroFilas;
PColumnas->Caption = NumeroColumnas;
X1 = Y1 = 0;
X1F = Y1F = 0;
X2 = X2F = NumeroColumnas;
Y2 = Y2F = NumeroFilas;
PX1->Caption = X1;
PY1->Caption = Y1;
PX2->Caption = X2;
PY2->Caption = Y2;
PFil->Caption = NumeroFilas;
PCol->Caption = NumeroColumnas;
PB1->Width = X2 + 4;
PB1->Height = Y2 + 4;
delete BM1;
BM1 = new Graphics::TBitmap();
BM1->Height = NumeroFilas;
BM1->Width = NumeroColumnas;
BM1->PixelFormat = pf8bit;
BM1->Palette = CreatePalette(&SysPal.lpal);
TBBinin->Position = 1;
for (int y = 0; y < NumeroFilas; y++)
{
for (int x = 0; x < NumeroColumnas; x++)
{
Foto[y][x] = 0;
}
}
BitBlt(PB1->Canvas->Handle, 0, numeroLineaanterior, BM1->Width, nl - numeroLineaanterior,
BM1->Canvas->Handle, 0, numeroLineaanterior, SRCCOPY);
}