本文整理汇总了C++中Palette::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ Palette::Release方法的具体用法?C++ Palette::Release怎么用?C++ Palette::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Palette
的用法示例。
在下文中一共展示了Palette::Release方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFont
Font* BAMFontManager::GetFont(ieWord FirstChar,
ieWord LastChar,
unsigned short /*ptSize*/,
FontStyle /*style*/, Palette* pal)
{
AnimationFactory* af = bamImp->GetAnimationFactory("dummy"); // FIXME: how does this get released?
unsigned int i = 0, glyphIndexOffset = 0, limit = 0, Count = 0, glyphCount = 0;
unsigned int CyclesCount = af->GetCycleCount();
// Numeric fonts have all frames in single cycle
if (CyclesCount > 1) {
Count = CyclesCount;
glyphCount = (LastChar - FirstChar + 1);
if (Count < glyphCount){
LastChar = LastChar - (glyphCount - Count);
glyphCount = Count;
}
i = (FirstChar) ? FirstChar - 1 : FirstChar;
limit = (FirstChar) ? LastChar - 1 : LastChar;
glyphIndexOffset = i;
} else { //numeric font
Count = af->GetFrameCount();
glyphCount = Count;
if (FirstChar+Count != (unsigned int) LastChar+1) {
Log(ERROR, "BAMFontManager", "inconsistent font %s: FirstChar=%d LastChar=%d Count=%d",
str->filename, FirstChar, LastChar, Count);
return NULL;
}
limit = glyphCount - 1;
}
Sprite2D** glyphs = (Sprite2D**)malloc( glyphCount * sizeof(Sprite2D*) );
for (; i <= limit; i++) {
if (CyclesCount > 1) {
glyphs[i - glyphIndexOffset] = af->GetFrame(0, i);
// Hack to work around original data where some status icons have inverted x and y positions (ie level up icon)
// isStateFont is set in Open() and simply compares the first 6 characters of the file with "STATES"
if (isStateFont) {
// since initials and state icons should all be the same size/position we can just take the position of the first one
glyphs[i - glyphIndexOffset]->YPos = glyphs[0]->YPos;
}
} else {
glyphs[i - glyphIndexOffset] = af->GetFrameWithoutCycle(i);
glyphs[i - glyphIndexOffset]->YPos = 13 - glyphs[i - glyphIndexOffset]->Height;
}
}
// assume all sprites have same palette
Palette* palette = glyphs[0]->GetPalette();
Font* fnt = new Font(glyphs, FirstChar, LastChar, palette);
palette->Release();
if (pal) {
fnt->SetPalette(pal);
}
return fnt;
}
示例2: GetFrameInternal
Sprite2D* BAMImporter::GetFrameInternal(unsigned short findex, unsigned char mode,
bool BAMsprite, const unsigned char* data,
AnimationFactory* datasrc)
{
Sprite2D* spr = 0;
if (BAMsprite) {
bool RLECompressed = (frames[findex].FrameData & 0x80000000) == 0;
assert(data);
const unsigned char* framedata = data;
framedata += (frames[findex].FrameData & 0x7FFFFFFF) - DataStart;
if (RLECompressed) {
spr = core->GetVideoDriver()->CreateSpriteBAM8(
frames[findex].Width, frames[findex].Height,
true, framedata, datasrc, palette, CompressedColorIndex);
} else {
spr = core->GetVideoDriver()->CreateSpriteBAM8(
frames[findex].Width, frames[findex].Height, false,
framedata, datasrc, palette, CompressedColorIndex );
}
} else {
void* pixels = GetFramePixels(findex);
spr = core->GetVideoDriver()->CreateSprite8(
frames[findex].Width, frames[findex].Height, 8,
pixels, palette->col, true, 0 );
}
spr->XPos = (ieWordSigned)frames[findex].XPos;
spr->YPos = (ieWordSigned)frames[findex].YPos;
if (mode == IE_SHADED) {
// CHECKME: is this ever used? Should we modify the sprite's palette
// without creating a local copy for this sprite?
Palette* pal = spr->GetPalette();
pal->CreateShadedAlphaChannel();
pal->Release();
}
return spr;
}
示例3: Draw
/** Draws the Control on the Output Display */
void WorldMapControl::Draw(unsigned short XWin, unsigned short YWin)
{
WorldMap* worldmap = core->GetWorldMap();
if (!Width || !Height) {
return;
}
if(!Changed)
return;
Changed = false;
Video* video = core->GetVideoDriver();
Region r( XWin+XPos, YWin+YPos, Width, Height );
Region clipbackup;
video->GetClipRect(clipbackup);
video->SetClipRect(&r);
video->BlitSprite( worldmap->GetMapMOS(), MAP_TO_SCREENX(0), MAP_TO_SCREENY(0), true, &r );
unsigned int i;
unsigned int ec = worldmap->GetEntryCount();
for(i=0;i<ec;i++) {
WMPAreaEntry *m = worldmap->GetEntry(i);
if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;
int xOffs = MAP_TO_SCREENX(m->X);
int yOffs = MAP_TO_SCREENY(m->Y);
Sprite2D* icon = m->GetMapIcon(worldmap->bam);
if( icon ) {
if (m == Area) {
Palette *pal = icon->GetPalette();
icon->SetPalette(pal_selected);
video->BlitSprite( icon, xOffs, yOffs, true, &r );
icon->SetPalette(pal);
pal->Release();
} else {
video->BlitSprite( icon, xOffs, yOffs, true, &r );
}
video->FreeSprite( icon );
}
if (AnimPicture && !strnicmp(m->AreaResRef, currentArea, 8) ) {
video->BlitSprite( AnimPicture, xOffs, yOffs, true, &r );
}
}
// Draw WMP entry labels
if (ftext==NULL) {
video->SetClipRect(&clipbackup);
return;
}
for(i=0;i<ec;i++) {
WMPAreaEntry *m = worldmap->GetEntry(i);
if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;
Sprite2D *icon=m->GetMapIcon(worldmap->bam);
int h=0,w=0,xpos=0,ypos=0;
if (icon) {
h=icon->Height;
w=icon->Width;
xpos=icon->XPos;
ypos=icon->YPos;
video->FreeSprite( icon );
}
Region r2 = Region( MAP_TO_SCREENX(m->X-xpos), MAP_TO_SCREENY(m->Y-ypos), w, h );
if (!m->GetCaption())
continue;
int tw = ftext->CalcStringWidth( (unsigned char*)m->GetCaption() ) + 5;
int th = ftext->maxHeight;
Palette* text_pal = pal_normal;
if (Area == m) {
text_pal = pal_selected;
} else {
if (! (m->GetAreaStatus() & WMP_ENTRY_VISITED)) {
text_pal = pal_notvisited;
}
}
ftext->Print( Region( r2.x + (r2.w - tw)/2, r2.y + r2.h, tw, th ),
( const unsigned char * ) m->GetCaption(), text_pal, 0, true );
}
video->SetClipRect(&clipbackup);
}