// JP opened flex table

Click to See Complete Forum and Search --> : question


celtics
December 18th, 2003, 12:11 AM
this works fine. this runs in a loop. loop could go faster.
how may i modify this section of my mfc/sdi app
to make things display faster (OnDraw(CDC* dc) get called
in a loop)?. like moving big chunk of this to somewhere
else..??

void CMyView::OnDraw(CDC* dc)
{
CMemDC pDC(dc);
CPalette* pOldPalette = NULL;
CPalette pal;
COLORADJUSTMENT cahalf;
HDC hdc = pDC->GetSafeHdc();
LPBITMAPINFO bInfo = (LPBITMAPINFO)new BYTE[sizeof(BITMAPINFOHEADER) +
256 * sizeof(RGBQUAD)];
bInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bInfo->bmiHeader.biWidth = Width;
bInfo->bmiHeader.biHeight = Height;
bInfo->bmiHeader.biPlanes = 1;
bInfo->bmiHeader.biBitCount = 8;
bInfo->bmiHeader.biCompression = 0;
bInfo->bmiHeader.biSizeImage = 0;
bInfo->bmiHeader.biXPelsPerMeter = 0;
bInfo->bmiHeader.biYPelsPerMeter = 0;
bInfo->bmiHeader.biClrUsed = 0;
bInfo->bmiHeader.biClrImportant = 0;

int nColors = bInfo->bmiHeader.biClrUsed ? bInfo->bmiHeader.biClrUsed : 1 << bInfo->bmiHeader.biBitCount;

// The device supports a palette and bitmap has color table

// Allocate memory for a palette
UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * nColors);
LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];

pLP->palVersion = 0x300;
pLP->palNumEntries = nColors;

for( int i=0; i < nColors; i++)
{
bInfo->bmiColors[i].rgbRed = i;
bInfo->bmiColors[i].rgbGreen = i;
bInfo->bmiColors[i].rgbBlue = i;
bInfo->bmiColors[i].rgbReserved = 0;
}
pal.CreatePalette( pLP );

delete[] pLP;

// Select the palette
SetStretchBltMode(hdc,HALFTONE);
SetColorAdjustment(hdc,&cahalf);
pOldPalette = pDC->SelectPalette(&pal, FALSE);
pDC->RealizePalette();

StretchDIBits( hdc, 0, 0,
Wt,
Ht,
0, 0,
Width,
Height,
pData,
bInfo,
DIB_RGB_COLORS,
SRCCOPY );

delete [] bInfo;
ReleaseDC(pDC);
}

//JP added flex table