本文整理汇总了C++中wxImage::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ wxImage::Clear方法的具体用法?C++ wxImage::Clear怎么用?C++ wxImage::Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxImage
的用法示例。
在下文中一共展示了wxImage::Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Piano_load_shapes
//all shapes are loaded from same image file to reduce file I/O and caching
//thiss also allows animated images to be self-contained
void PianoRenderCache::Piano_load_shapes(RenderBuffer &buffer, const wxString& filename)
{
debug_function(10); //Debug debug("load_shapes('%s')", (const char*)filename.c_str());
debug(1, "load shapes file '%s'", (const char*)filename.c_str());
//reload shapes even if file name hasn't changed; color map might be different now
// if (!CachedShapeFilename.CmpNoCase(filename)) { debug_more(2, ", no change"); return; } //no change
if (!wxFileExists(filename)) return;
Piano_flush_shapes(); //invalidate cached data
if (!Shapes.LoadFile(filename, wxBITMAP_TYPE_ANY, 0) || !Shapes.IsOk())
{
//wxMessageBox("Error loading image file: "+NewPictureName);
Shapes.Clear();
return;
}
if (buffer.GetColorCount() < 2) return; //use colors from shapes file if no user-selected colors
// int imgwidth=image.GetWidth();
// int imght =image.GetHeight();
// std::hash_map<WXCOLORREF, int> palcounts;
//TODO: use wxImage.GetData for better performance?
//TODO: use multiple images within same file?
for (int y = Shapes.GetHeight() - 1; y >= 0; --y) //bottom->top
for (int x = 0; x < Shapes.GetWidth(); ++x) //left->right
if (!Shapes.IsTransparent(x, y))
{
xlColor color, mapped;
color.Set(Shapes.GetRed(x, y), Shapes.GetGreen(x, y), Shapes.GetBlue(x, y));
if (ColorMap.find(color.GetRGB()) != ColorMap.end()) continue; //already saw this color
buffer.palette.GetColor(ColorMap.size() % buffer.GetColorCount(), mapped); //assign user-selected colors to shape palette sequentially, loop if run out of colors
debug(10, "shape color[%d] 0x%x => user-selected color [%d] 0x%x", ColorMap.size(), color.GetRGB(), ColorMap.size() % GetColorCount(), mapped.GetRGB());
ColorMap[color.GetRGB()] = mapped; //.GetRGB();
// ShapePalette.push_back(c.GetRGB()); //keep a list of unique colors in order of occurrence from origin L-R, B-T
}
debug(2, "w %d, h %d, #colors %d", Shapes.GetWidth(), Shapes.GetHeight(), ColorMap.size());
CachedShapeFilename = filename; //don't load same file again
}