Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Embedding a BMP Image into an XML Document with Zip Data CompressionDownloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries 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;
}
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.