本文整理汇总了C++中CBitmap::AvgColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitmap::AvgColor方法的具体用法?C++ CBitmap::AvgColor怎么用?C++ CBitmap::AvgColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitmap
的用法示例。
在下文中一共展示了CBitmap::AvgColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadReplacementBitmaps
void LoadReplacementBitmaps (const char *pszLevelName)
{
char szFilename [SHORT_FILENAME_LEN];
CFile cf;
int i, j;
CBitmap bm;
//first, free up data allocated for old bitmaps
PrintLog (" loading replacement textures\n");
CFile::ChangeFilenameExtension (szFilename, pszLevelName, ".pog");
if (cf.Open (szFilename, gameFolders.szDataDir, "rb", 0)) {
int id, version, nBitmapNum, bTGA;
int bmDataSize, bmDataOffset, bmOffset;
ushort *indices;
tPIGBitmapHeader *bmh;
id = cf.ReadInt ();
version = cf.ReadInt ();
if (id != MAKE_SIG ('G','O','P','D') || version != 1) {
cf.Close ();
return;
}
nBitmapNum = cf.ReadInt ();
indices = new ushort [nBitmapNum];
bmh = new tPIGBitmapHeader [nBitmapNum];
#if 0
cf.Read (indices, nBitmapNum * sizeof (ushort), 1);
cf.Read (bmh, nBitmapNum * sizeof (tPIGBitmapHeader), 1);
#else
for (i = 0; i < nBitmapNum; i++)
indices [i] = cf.ReadShort ();
for (i = 0; i < nBitmapNum; i++)
PIGBitmapHeaderRead (bmh + i, cf);
#endif
bmDataOffset = cf.Tell ();
bmDataSize = cf.Length () - bmDataOffset;
for (i = 0; i < nBitmapNum; i++) {
bmOffset = bmh [i].offset;
memset (&bm, 0, sizeof (CBitmap));
bm.AddFlags (bmh [i].flags & (BM_FLAGS_TO_COPY | BM_FLAG_TGA));
bm.SetWidth (bmh [i].width + ((short) (bmh [i].wh_extra & 0x0f) << 8));
bm.SetRowSize (bm.Width ());
if ((bTGA = (bm.Flags () & BM_FLAG_TGA)) && (bm.Width () > 256))
bm.SetHeight (bm.Width () * bmh [i].height);
else
bm.SetHeight (bmh [i].height + ((short) (bmh [i].wh_extra & 0xf0) << 4));
bm.SetBPP (bTGA ? 4 : 1);
if (!(bm.Width () * bm.Width ()))
continue;
bm.SetAvgColorIndex (bmh [i].avgColor);
bm.SetType (BM_TYPE_ALT);
if (!bm.CreateBuffer ())
break;
cf.Seek (bmDataOffset + bmOffset, SEEK_SET);
#if DBG
if (indices [i] == nDbgTexture)
nDbgTexture = nDbgTexture;
#endif
if (bTGA) {
int nFrames = bm.Height () / bm.Width ();
tTgaHeader h;
h.width = bm.Width ();
h.height = bm.Width ();
h.bits = 32;
if (!ReadTGAImage (cf, &h, &bm, -1, 1.0, 0, 1)) {
bm.DestroyBuffer ();
break;
}
bm.SetFrameCount ((ubyte) nFrames);
if (nFrames > 1) {
tEffectClip *ecP = NULL;
tWallClip *wcP;
tVideoClip *vcP;
while ((ecP = FindEffect (ecP, indices [i]))) {
//e->vc.nFrameCount = nFrames;
ecP->flags |= EF_ALTFMT | EF_FROMPOG;
}
if (!ecP) {
if ((wcP = FindWallAnim (indices [i]))) {
//w->nFrameCount = nFrames;
wcP->flags |= WCF_ALTFMT | WCF_FROMPOG;
}
else if ((vcP = FindVClip (i))) {
//v->nFrameCount = nFrames;
vcP->flags |= WCF_ALTFMT | WCF_FROMPOG;
}
}
}
j = indices [i];
bm.SetId (j);
}
else {
#if DBG
if (j == nDbgTexture)
nDbgTexture = nDbgTexture;
#endif
ReadBitmap (&bm, int (bm.Width ()) * int (bm.Height ()), &cf, true, false);
j = indices [i];
//.........这里部分代码省略.........