Example #1
0
SBrush::SBrush(string name)
{

	image = nullptr;
	this->name = name;
	icon = name.AfterFirst('_');
	cx = 0;
	cy = 0;

	Archive* res = App::archiveManager().programResourceArchive();
	if (res == nullptr)
		return;
	ArchiveEntry* file = res->entryAtPath(S_FMT("icons/general/%s.png", icon));
	if (file == nullptr || file->getSize() == 0)
	{
		LOG_MESSAGE(2, "error, no file at icons/general/%s.png", icon);
		return;
	}
	image = new SImage();
	if (!image->open(file->getMCData(), 0, "png"))
	{
		LOG_MESSAGE(2, "couldn't load image data for icons/general/%s.png", icon);
		return;
	}
	image->convertAlphaMap(SImage::ALPHA);
	cx = image->getWidth() >> 1;
	cy = image->getHeight() >> 1;

	theBrushManager->add(this);
}