Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Embedding a BMP Image into an XML Document with Zip Data Compression
Source Code Listing // Store a Zip compressed BMP image in an XML file.
void CreateBmpXml(void)
{
// Our XML document.
CkXml xml;
xml.put_Tag("root");
// Load a file.
CkByteData byteData;
byteData.loadFile("dudeCPP.bmp");
// Create a child XML node to hold the BMP image.
CkXml *node = xml.NewChild("bmp_image","");
// Add the filename as an attribute.
node->AddAttribute("filename","dudeCPP.bmp");
// Add the binary data (and Zip compress it.)
bool zipCompress = true;
bool aesEncrypt = false;
const char *aesPassword = 0;
node->SetBinaryContent(byteData.getData(),byteData.getSize(),zipCompress,aesEncrypt,aesPassword);
// Save the XML.
xml.SaveXml("BmpImage.xml");
// Access the binary data and save it to another BMP to
// prove that the data is preserved.
CkByteData b;
node->GetBinaryContent(b,zipCompress,aesEncrypt,aesPassword);
b.saveFile("dudeOut.bmp");
delete node;
return;
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.