int CStatBox::CalcWidth()
{
    //find longest line of text
    int length = 0;
    int longest = 0;
    CSurface* line;
    for(int i = 0; i<lines->size(); i++)
    {
        line = lines->at(i);
        if(line != NULL)
        {
            length = line->GetWidth();
            if(length > longest)
            {
                longest = length;
            }
        }

    }
    return longest;
}
Esempio n. 2
0
bool CTgaWriter::Write(const std::string& fileName, CSurface& surface)
{

	m_FileName=fileName;
	//file = IGenericFile::Open(fileName.c_str(), IGenericFile::OPEN_READ | IGenericFile::OPEN_BINARY | IGenericFile::OPEN_STANDALONE, false, true);
	m_File.open(fileName.c_str(),std::ios::out|std::ios::binary);
	if(!m_File)return false;

	memset(&m_Header,0,sizeof(m_Header));
	

	m_Header.Width=surface.GetWidth();
	m_Header.Height=surface.GetHeight();
	m_Header.Bits=surface.GetDepth()<<3;

	if(surface.GetFormat()==CSurface::EFormat_A8R8G8B8 || surface.GetFormat()==CSurface::EFormat_R8G8B8 || surface.GetFormat()==CSurface::EFormat_X8R8G8B8){
		m_Header.ImageType=2;
	}else if(surface.GetFormat()==CSurface::EFormat_S8){
		m_Header.ImageType=3;
	}


	// Write header
	m_Header.Write(m_File);
	if(!m_File)return false;

	// Write data
	m_File.write((char*)surface.GetDataPointer(),surface.GetSize());

	// Close and bail out
	if(!m_File)return false;
	m_File.close();
	return true;


}