本文整理汇总了C++中GraphicsWindow::getDIB方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsWindow::getDIB方法的具体用法?C++ GraphicsWindow::getDIB怎么用?C++ GraphicsWindow::getDIB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsWindow
的用法示例。
在下文中一共展示了GraphicsWindow::getDIB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MAXBitMap
//DIB Methods
Value*
getViewportDib_cf(Value** arg_list, int count)
{
check_arg_count(getViewportDib, 0, count);
GraphicsWindow *gw = MAXScript_interface->GetActiveViewExp().getGW();
BITMAPINFO *bmi = NULL;
BITMAPINFOHEADER *bmih;
BitmapInfo bi;
Bitmap *bmp;
int size;
gw->getDIB(NULL, &size);
bmi = (BITMAPINFO *)malloc(size);
bmih = (BITMAPINFOHEADER *)bmi;
gw->getDIB(bmi, &size);
bi.SetWidth((WORD)bmih->biWidth);
bi.SetHeight((WORD)bmih->biHeight);
bi.SetType(BMM_TRUE_32);
UWORD *gammatab = NULL;
IColorCorrectionMgr* idispGamMgr = (IColorCorrectionMgr*) GetCOREInterface(COLORCORRECTIONMGR_INTERFACE);
float gamma = 1.0f; // default if off
if(gammaMgr.IsEnabled() && idispGamMgr)
{
gamma = idispGamMgr->GetGamma();
gammatab = new UWORD[RCOLN];
// Build gamma correction table
if (gammatab)
BuildGammaTab(gammatab, 1.0f/gamma, true);
// To gamma-correct we need 64 bits resolution
bi.SetType(BMM_TRUE_64);
}
bi.SetGamma(1.0f); // New bitmap will be linear
bmp = CreateBitmapFromBitmapInfo(bi); // Make new, linear bitmap
bmp->FromDib(bmi);
free(bmi); // JBW 10.7.99: missing free(), elided above I/O, not desired
// If gamma is on:
/* EXPLANATION:
The code that saves a bitmap always assumes the bitmap to be saved comes from the renderer,
and hence, is linear. Since we are grabbing off the viewport (with an embedded gamma) we
need to linearize the bitmap first */
if (gammatab)
{
// We still want this to be SAVED with a gamma. What gamma MaxScript will save
// this with (by default) is defined by the gamma of the BitmapInfo bi's gamma
// And we intentionally want it to look like it was displayed - hence we use the
// display gamma!!
bi.SetGamma(gamma);
int h = bmp->Height();
int w = bmp->Width();
BMM_Color_64 *pixelrow = (BMM_Color_64 *)LocalAlloc(LPTR,w*sizeof(BMM_Color_64));
if (pixelrow)
{
for (int iy = 0; iy < h; iy++) {
bmp->GetPixels(0, iy, w, pixelrow);
for (int ix = 0; ix < w; ix++) {
pixelrow[ix].r = gammatab[UWORD(pixelrow[ix].r) >> RCSH16];
pixelrow[ix].g = gammatab[UWORD(pixelrow[ix].g) >> RCSH16];
pixelrow[ix].b = gammatab[UWORD(pixelrow[ix].b) >> RCSH16];
}
bmp->PutPixels(0, iy, w, pixelrow);
}
LocalFree(pixelrow);
}
delete [] gammatab;
}
return new MAXBitMap(bi, bmp);
}