本文整理汇总了C++中BitmapInfo::SetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapInfo::SetWidth方法的具体用法?C++ BitmapInfo::SetWidth怎么用?C++ BitmapInfo::SetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapInfo
的用法示例。
在下文中一共展示了BitmapInfo::SetWidth方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderFrame
void UtilTest::RenderFrame()
{
int res;
// Create a blank bitmap
static Bitmap *bm = NULL;
if (!bm) {
BitmapInfo bi;
bi.SetWidth(320);
bi.SetHeight(200);
bi.SetType(BMM_TRUE_64);
bi.SetFlags(MAP_HAS_ALPHA);
bi.SetAspect(1.0f);
bm = TheManager->Create(&bi);
}
// Get the active viewport to render
// Display the bitmap
bm->Display(_T("Test"));
// Open up the renderer, render a frame and close it.
res = ip->OpenCurRenderer(NULL,ip->GetActiveViewExp().ToPointer());
res = ip->CurRendererRenderFrame(
ip->GetTime(),bm);
ip->CloseCurRenderer();
// We're done with the viewport.
}
示例2: BuildBitmap
Bitmap* UVtex::BuildBitmap(int size) {
float u,v;
BitmapInfo bi;
bi.SetName(_T("uvTexTemp"));
bi.SetWidth(size);
bi.SetHeight(size);
bi.SetType(BMM_TRUE_32);
Bitmap *bm = TheManager->Create(&bi);
if (bm==NULL) return NULL;
PixelBuf l64(size);
float d = 1.0f/float(size);
v = 0.0f;
for (int y=0; y<size; y++) {
BMM_Color_64 *p64=l64.Ptr();
u = 0.0f;
for (int x=0; x<size; x++, p64++) {
Color c = EvalUVtex( Point3(u,(1.0f-v),0.0f) );
p64->r = FlToWord(c.r);
p64->g = FlToWord(c.g);
p64->b = FlToWord(c.b);
p64->a = 0xffff;
u += d;
}
bm->PutPixels(0,y, size, l64.Ptr());
v += d;
}
return bm;
}
示例3: DispEvalFunc
Bitmap *Gradient::BuildBitmap(int size) {
float u,v;
BitmapInfo bi;
static MaxSDK::AssetManagement::AssetUser bitMapAssetUser;
if (bitMapAssetUser.GetId() == MaxSDK::AssetManagement::kInvalidId)
bitMapAssetUser = MaxSDK::AssetManagement::IAssetManager::GetInstance()->GetAsset(GetString(IDS_RB_GRADTEMP), MaxSDK::AssetManagement::kBitmapAsset);
bi.SetAsset(bitMapAssetUser);
bi.SetWidth(size);
bi.SetHeight(size);
bi.SetType(BMM_TRUE_32);
Bitmap *bm = TheManager->Create(&bi);
if (bm==NULL) return NULL;
PixelBuf l64(size);
float d = 1.0f/float(size);
v = 1.0f - 0.5f*d;
for (int y=0; y<size; y++) {
BMM_Color_64 *p64=l64.Ptr();
u = 0.0f;
for (int x=0; x<size; x++, p64++) {
AColor c = DispEvalFunc(u,v);
p64->r = FlToWord(c.r);
p64->g = FlToWord(c.g);
p64->b = FlToWord(c.b);
p64->a = 0xffff;
u += d;
}
bm->PutPixels(0,y, size, l64.Ptr());
v -= d;
}
return bm;
}
示例4: c
Bitmap *PainterTextureSample::BuildBitmap(int size)
{
float u,v;
BitmapInfo bi;
bi.SetName(_T("checkerTemp"));
bi.SetWidth(size);
bi.SetHeight(size);
bi.SetType(BMM_TRUE_32);
if (bm == NULL)
{
bm = TheManager->Create(&bi);
if (bm==NULL) return NULL;
PixelBuf l64(size);
float d = 1.0f/float(size);
v = 1.0f - 0.5f*d;
for (int y=0; y<size; y++) {
BMM_Color_64 *p64=l64.Ptr();
u = 0.0f;
for (int x=0; x<size; x++, p64++) {
AColor c(0.0f,0.0f,0.0f) ;
p64->r = FlToWord(c.r);
p64->g = FlToWord(c.g);
p64->b = FlToWord(c.b);
p64->a = 0xffff;
u += d;
}
bm->PutPixels(0,y, size, l64.Ptr());
v -= d;
}
}
width = size;
return bm;
}
示例5: DispEvalFunc
Bitmap *Gradient::BuildBitmap(int size) {
float u,v;
BitmapInfo bi;
bi.SetName(GetString(IDS_RB_GRADTEMP));
bi.SetWidth(size);
bi.SetHeight(size);
bi.SetType(BMM_TRUE_32);
Bitmap *bm = TheManager->Create(&bi);
if (bm==NULL) return NULL;
PixelBuf l64(size);
float d = 1.0f/float(size);
v = 1.0f - 0.5f*d;
for (int y=0; y<size; y++) {
BMM_Color_64 *p64=l64.Ptr();
u = 0.0f;
for (int x=0; x<size; x++, p64++) {
AColor c = DispEvalFunc(u,v);
p64->r = FlToWord(c.r);
p64->g = FlToWord(c.g);
p64->b = FlToWord(c.b);
p64->a = 0xffff;
u += d;
}
bm->PutPixels(0,y, size, l64.Ptr());
v -= d;
}
return bm;
}
示例6: AllocMap
int PlateMap::AllocMap(int w, int h) {
if ( bm && w==bm->Width() && h==bm->Height())
return 1;
BitmapInfo bi;
if (bm) bm->DeleteThis();
bi.SetName(_T(""));
bi.SetWidth(w);
bi.SetHeight(h);
bi.SetType(BMM_TRUE_32);
bi.SetCustomFlag(BMM_CUSTOM_GAMMA);
bi.SetCustomGamma(1.0f);
bm = TheManager->Create(&bi);
// bm->CreateChannels(BMM_CHAN_Z);
return 1;
}
示例7: GetCOREInterface
void DxStdMtl2::LoadTextureData(IHLSLCodeGenerator * codeGen)
{
Bitmap * bmap;
BitmapInfo stBI;
TimeValue t = GetCOREInterface()->GetTime();
int nWidth,nHeight;
int numberOfTextures = elementContainer.NumberofElementsByType(EffectElements::kEleTex);
for(int i=0; i<numberOfTextures;i++)
{
bool bBump;
TextureElement * texEle = static_cast<TextureElement*>(elementContainer.GetElementByType(i,EffectElements::kEleTex));
TSTR mapType = texEle->GetMapName();
Texmap *texmap = codeGen->GetShaderDefinedTexmap(map,mapType.data(),bBump);
if(texmap)
{
BMM_Color_64 *p;
nWidth = nHeight = DIMDEFAULT;
BitmapDimensions(nWidth,nHeight,texmap);
// load and create the D3D texture;
/* if(texmap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0))
{
BitmapTex *pBT;
Bitmap *pTex;
pBT = (BitmapTex *)texmap;
pTex = pBT->GetBitmap(t);
if (pTex)
{
nWidth = getClosestPowerOf2(pTex->Width());
nHeight = getClosestPowerOf2(pTex->Height());
}
}
*/
stBI.SetType(BMM_TRUE_32);
stBI.SetWidth(nWidth);
stBI.SetHeight(nHeight);
bmap = TheManager->Create(&stBI);
if (bmap)
{
// LPDIRECT3DTEXTURE9 pRenderTex = texEle->GetD3DTexture();
texmap->RenderBitmap(t, bmap, MAPSCALE3D * 2.0f);
p = new BMM_Color_64[nWidth*nHeight];
for (int y = 0; y < nHeight; y++)
bmap->GetLinearPixels(0, y, nWidth, p + y * nWidth);
if(texEle->pTex)
{
D3DSURFACE_DESC stLD;
texEle->pTex->GetLevelDesc(0, &stLD);
if (stLD.Width != nWidth || stLD.Height != nHeight)
{
SAFE_RELEASE(texEle->pTex);
}
}
if(!texEle->pTex)
pd3dDevice->CreateTexture(nWidth,nHeight, 0,D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&texEle->pTex, NULL);
if(texEle->pTex)
{
PIXELFMT *pT;
D3DLOCKED_RECT stLR;
texEle->pTex->LockRect(0, &stLR, 0, 0);
pT = (PIXELFMT *)stLR.pBits;
for (int i = 0; i < nWidth * nHeight; i++)
{
pT[i].r = p[i].r >> 8;
pT[i].g = p[i].g >> 8;
pT[i].b = p[i].b >> 8;
pT[i].a = p[i].a >> 8;
}
texEle->pTex->UnlockRect(0);
if(bBump && texmap->ClassID() != GNORMAL_CLASS_ID)
{
// LPDIRECT3DTEXTURE9 normalTex = texEle->GetD3DBumpTexture();
if(texEle->pBumpTex)
{
D3DSURFACE_DESC stLD;
texEle->pBumpTex->GetLevelDesc(0, &stLD);
if (stLD.Width != nWidth || stLD.Height != nHeight)
{
SAFE_RELEASE(texEle->pBumpTex);
}
}
if(!texEle->pBumpTex)
pd3dDevice->CreateTexture(nWidth,nHeight, 0,D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&texEle->pBumpTex, NULL);
D3DXComputeNormalMap(texEle->pBumpTex,texEle->pTex,NULL, NULL, D3DX_CHANNEL_RED,30.0f);
if(texEle->GetParamHandle())
//.........这里部分代码省略.........
示例8: GetCOREInterface
void plStaticEnvLayer::RenderCubicMap( INode *node )
{
int res, size;
BOOL success = 0;
TSTR fname, fullname;
Bitmap *bm = NULL;
TSTR path, filename, ext, thisFilename;
BitmapInfo biOutFile;
static TCHAR suffixes[ 6 ][ 4 ] = { "_FR", "_BK", "_LF", "_RT", "_UP", "_DN" };
Interface *ip = GetCOREInterface();
size = fBitmapPB->GetInt( kBmpTextureSize, ip->GetTime() );
if( size <= 0 )
{
return;
}
thisFilename = fBitmapPB->GetStr( kBmpBaseFilename, ip->GetTime() );
if( thisFilename.isNull() )
{
return;
}
SplitFilename( thisFilename, &path, &filename, &ext );
BOOL wasHid = node->IsNodeHidden();
node->Hide( TRUE );
// Create a blank bitmap
biOutFile.SetWidth( size );
biOutFile.SetHeight( size );
biOutFile.SetType( BMM_TRUE_64 );
biOutFile.SetAspect( 1.0f );
biOutFile.SetCurrentFrame( 0 );
bm = TheManager->Create( &biOutFile );
Matrix3 nodeTM = node->GetNodeTM( ip->GetTime() );
Matrix3 tm;
INode *root = ip->GetRootNode();
bm->Display( GetString( IDS_CUBIC_RENDER_TITLE ) );
/// Set up rendering contexts
ViewParams vp;
vp.projType = PROJ_PERSPECTIVE;
vp.hither = .001f;
vp.yon = 1.0e30f;
vp.fov = M_PI/2.0f;
if( fBitmapPB->GetInt( kBmpUseMAXAtmosphere ) )
{
vp.nearRange = 0;
vp.farRange = fBitmapPB->GetFloat( kBmpFarDistance );
}
else
{
vp.nearRange = vp.farRange = 1.0e30f;
}
BOOL saveUseEnvMap = ip->GetUseEnvironmentMap();
ip->SetUseEnvironmentMap( false );
res = ip->OpenCurRenderer( &vp );
for( int i = 0; i < 6; i++ )
{
tm = IGetViewTM( i );
tm.PreTranslate( -nodeTM.GetTrans() );
vp.affineTM = tm;
// Construct filename
thisFilename.printf( _T( "%s\\%s%s%s" ), path, filename, suffixes[ i ], ext );
res = ip->CurRendererRenderFrame( ip->GetTime(), bm, NULL, 1.0f, &vp );
if( !res )
goto fail;
if( !IWriteBM( &biOutFile, bm, thisFilename ) )
goto fail;
}
success = 1;
fail:
ip->CloseCurRenderer();
ip->SetUseEnvironmentMap( saveUseEnvMap );
bm->DeleteThis();
node->Hide( wasHid );
if( success )
{
for(int i = 0; i < 6; i++ )
{
BitmapInfo bi;
thisFilename.printf( _T( "%s\\%s%s%s" ), path, filename, suffixes[ i ], ext );
bi.SetName( thisFilename );
PBBitmap pbBitmap( bi );
fBitmapPB->SetValue( kBmpFrontBitmap + i, ip->GetTime(), &pbBitmap );
}
fBitmapPB->GetMap()->UpdateUI( ip->GetTime() );
}
}
示例9: 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);
}
示例10: row
BITMAPINFO *plLayerTex::GetVPDisplayDIB(TimeValue t, TexHandleMaker& thmaker, Interval &valid, BOOL mono, BOOL forceW, BOOL forceH)
{
// FIXME
fTexTime = 0;//CalcFrame(t);
// texValid = clipValid;
BITMAPINFO *bmi = NULL;
int xflags = 0;
if (fBitmapPB->GetInt(kBmpApply))
{
float clipu = fBitmapPB->GetFloat(kBmpClipU);
float clipv = fBitmapPB->GetFloat(kBmpClipV);
float clipw = fBitmapPB->GetFloat(kBmpClipW);
float cliph = fBitmapPB->GetFloat(kBmpClipH);
int discardAlpha = fBitmapPB->GetInt(kBmpDiscardAlpha);
int alphaAsRGB = (fBitmapPB->GetInt(kBmpRGBOutput) == 1);
int w = fBM->Width();
int h = fBM->Height();
Bitmap *newBM;
BitmapInfo bi;
bi.SetName(_T("y8798734"));
bi.SetType(BMM_TRUE_32);
bi.SetFlags(MAP_HAS_ALPHA);
if (fBitmapPB->GetInt(kBmpCropPlace) == 1)
{
int x0, y0, nw, nh;
int bmw = thmaker.Size();
int bmh = int(float(bmw)*float(h)/float(w));
bi.SetWidth(bmw);
bi.SetHeight(bmh);
newBM = TheManager->Create(&bi);
newBM->Fill(0,0,0,0);
nw = int(float(bmw)*clipw);
nh = int(float(bmh)*cliph);
x0 = int(float(bmw-1)*clipu);
y0 = int(float(bmh-1)*clipv);
if (nw<1) nw = 1;
if (nh<1) nh = 1;
PixelBuf row(nw);
Bitmap *tmpBM;
BitmapInfo bif2;
bif2.SetName(_T("xxxx67878"));
bif2.SetType(BMM_TRUE_32);
bif2.SetFlags(MAP_HAS_ALPHA);
bif2.SetWidth(nw);
bif2.SetHeight(nh);
tmpBM = TheManager->Create(&bif2);
tmpBM->CopyImage(fBM, COPY_IMAGE_RESIZE_LO_QUALITY, 0);
BMM_Color_64* p1 = row.Ptr();
for (int y = 0; y<nh; y++)
{
tmpBM->GetLinearPixels(0,y, nw, p1);
if (alphaAsRGB)
{
for (int ix =0; ix<nw; ix++)
p1[ix].r = p1[ix].g = p1[ix].b = p1[ix].a;
}
if (discardAlpha)
{
for (int ix = 0; ix < nw; ix++)
p1[ix].a = 0xffff;
}
newBM->PutPixels(x0, y+y0, nw, p1);
}
tmpBM->DeleteThis();
bmi = thmaker.BitmapToDIB(newBM, fUVGen->SymFlags(), xflags, forceW, forceH);
newBM->DeleteThis();
}
else
{
int x0,y0,nw,nh;
x0 = int(float(w-1)*clipu);
y0 = int(float(h-1)*clipv);
nw = int(float(w)*clipw);
nh = int(float(h)*cliph);
if (nw<1) nw = 1;
if (nh<1) nh = 1;
bi.SetWidth(nw);
bi.SetHeight(nh);
PixelBuf row(nw);
newBM = TheManager->Create(&bi);
BMM_Color_64* p1 = row.Ptr();
for (int y = 0; y<nh; y++)
{
fBM->GetLinearPixels(x0,y+y0, nw, p1);
if (alphaAsRGB)
{
for (int ix = 0; ix < nw; ix++)
p1[ix].r = p1[ix].g = p1[ix].b = p1[ix].a;
}
if (discardAlpha)
{
for (int ix = 0; ix < nw; ix++)
p1[ix].a = 0xffff;
}
//.........这里部分代码省略.........
示例11: GetStaticFrame
AWDTexture *
AWDExporter::ExportTexture(AWD *awd, awd_ncache *ncache,Texmap* tex, Class_ID cid, int subNo, AWDMaterial * mat ) {
AWDTexture *awd_tex;
const char* name;
int name_len;
bool hasAlpha = false;
MSTR path;
awd_uint8 * buf;
int buf_len;
if (!tex) return NULL;
if (tex->ClassID() != Class_ID(BMTEX_CLASS_ID, 0x00) ) return NULL;
// texture already exist in cache
awd_tex = (AWDTexture *)awd_ncache_get( ncache, tex );
if( awd_tex ) return awd_tex;
BitmapTex *bmptex = (BitmapTex*)tex;
MaxSDK::AssetManagement::AssetUser asset = bmptex->GetMap();
hasAlpha = bmptex->GetBitmap( GetStaticFrame() )->HasAlpha();
if( !asset.GetFullFilePath(path) ) {
fprintf( logfile, " export !asset.GetFullFilePath(path) : %i \n", asset.GetType() );
fflush( logfile );
//return NULL;
}
fprintf( logfile, " export : %s \n", path );
fflush( logfile );
AWD_tex_type textype = EXTERNAL;
if( GetIncludeMaps() &&
asset.GetType() == MaxSDK::AssetManagement::kBitmapAsset
) {
const char * dot;
dot = strrchr(path,'.');
if( !strcmp(dot, ".jpg")||
!strcmp(dot, ".JPG")||
!strcmp(dot, ".jpeg")||
!strcmp(dot, ".JPEG")
) {
textype = EMBEDDED_JPEG;
} else if (
!strcmp(dot, ".png")||
!strcmp(dot, ".PNG")
) {
textype = EMBEDDED_PNG;
}
if( textype == 0 ) {
fprintf( logfile, " export texture : %s \n", path );
fflush( logfile );
// try to extract data
Bitmap *bmp = bmptex->GetBitmap( GetStaticFrame() );
BitmapInfo bi;
MaxSDK::Util::Path *temppath;
bi.SetWidth( bmp->Width() );
bi.SetHeight( bmp->Height() );
if( hasAlpha ) {
bi.SetType( BMM_TRUE_32 );
bi.SetFlags( MAP_HAS_ALPHA );
path = "C:\\Users\\lepersp\\Desktop\\temp\\awdexporttempjpg.png";
textype = EMBEDDED_PNG;
} else {
bi.SetType( BMM_TRUE_24 );
path = "C:\\Users\\lepersp\\Desktop\\temp\\awdexporttempjpg.jpg";
textype = EMBEDDED_JPEG;
}
temppath = new MaxSDK::Util::Path( path );
bi.SetPath( *temppath );
bmp->OpenOutput( & bi );
bmp->Write( & bi );
bmp->Close(& bi);
}
//.........这里部分代码省略.........