Example #1
0
bool trpgwImageHelper::AddLocal(char *name,trpgTexture::ImageType type,int sizeX,int sizeY,
                                bool isMipmap,char *data,int &texID,bool deferWrite)
{
    // Set up the basic texture
    trpgTexture tex;
    if(texID!=-1)
        tex.SetHandle(texID);
    tex.SetName(name);
    tex.SetImageMode(trpgTexture::Local);
    tex.SetImageType(type);
    int depth;
    tex.GetImageDepth(depth);
    tex.SetNumLayer(depth);
    tex.SetImageSize(trpg2iPoint(sizeX,sizeY));
    tex.SetIsMipmap(isMipmap);

    // Write the image out to disk
    trpgwAppAddress addr;
    if(!deferWrite)
        if (!WriteToArchive(tex,data,addr,true))
            return false;

    // Now add the specifics to the texture table
    tex.SetImageAddr(addr);
    texID = texTable->AddTexture(tex);

    return true;
}
Example #2
0
bool trpgwImageHelper::AddTileLocal(char *name, trpgTexture::ImageType type, int sizeX, int sizeY,
                                    bool isMipmap, char *data, int &texID, trpgwAppAddress &addr)
{
    // Set up the texture template and add to the table
    trpgTexture tex;

    if (texID != -1)
        tex.SetHandle(texID);

    tex.SetName(name);
    tex.SetImageMode(trpgTexture::Template);
    tex.SetImageType(type);
    int depth;
    tex.GetImageDepth(depth);
    tex.SetNumLayer(depth);
    tex.SetImageSize(trpg2iPoint(sizeX, sizeY));
    tex.SetIsMipmap(isMipmap);
    texID = texTable->FindAddTexture(tex);

    // Write the specific data out to an archive (return the address)
    if (!WriteToArchive(tex, data, addr, false))
        return false;


    return true;
}
//****************************************************************************************
BOOL CBCGPGridSerializeManager::SerializeTo (CFile& file)
{
	ASSERT (m_pOwnerGrid != NULL);

	CArchive archive (&file, CArchive::store | CArchive::bNoFlushOnDelete);
	BOOL bResult = WriteToArchive (archive);
	archive.Close ();
	
	return bResult;
}
Example #4
0
bool trpgwImageHelper::ReplaceLocal(char *data,int &texID)
{
    const trpgTexture *texRef=texTable->GetTextureRef(texID);

    if (!texRef) return false;

    // Write the image out to disk
    trpgwAppAddress addr;
    if (!WriteToArchive(*texRef,data,addr,true))
        return false;

    // Now add the specifics to the texture table
    const_cast<trpgTexture *>(texRef)->SetImageAddr(addr);

    return true;
}
Example #5
0
void CEditView::Serialize(CArchive& ar)
	// Read and write CEditView object to archive, with length prefix.
{
	ASSERT_VALID(this);
	ASSERT(m_hWnd != NULL);
	if (ar.IsStoring())
	{
		UINT nLen = GetBufferLength();
		ar << (DWORD)nLen;
		WriteToArchive(ar);
	}
	else
	{
		DWORD dwLen;
		ar >> dwLen;
		if (dwLen > nMaxSize)
			AfxThrowArchiveException(CArchiveException::badIndex);
		UINT nLen = (UINT)dwLen;
		ReadFromArchive(ar, nLen);
	}
	ASSERT_VALID(this);
}
Example #6
0
void CEditView::SerializeRaw(CArchive& ar)
	// Read/Write object as stand-alone file.
{
	ASSERT_VALID(this);
	if (ar.IsStoring())
	{
		WriteToArchive(ar);
	}
	else
	{
		CFile* pFile = ar.GetFile();
		ASSERT(pFile->GetPosition() == 0);
		DWORD nFileSize = pFile->GetLength();
		if (nFileSize/sizeof(TCHAR) > nMaxSize)
		{
			AfxMessageBox(AFX_IDP_FILE_TOO_LARGE);
			AfxThrowUserException();
		}
		// ReadFromArchive takes the number of characters as argument
		ReadFromArchive(ar, (UINT)nFileSize/sizeof(TCHAR));
	}
	ASSERT_VALID(this);
}