|
|
|
@ -135,7 +135,7 @@ namespace Exiv2 {
|
|
|
|
|
DataBuf arr = parsePngChunk(pData, size, index, keysize);
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
std::cerr << "Exiv2::PngChunk::decode: Found PNG chunk: "
|
|
|
|
|
std::cerr << "Exiv2::PngChunk::decode: Found PNG chunk: "
|
|
|
|
|
<< std::string((const char*)key) << " :: "
|
|
|
|
|
<< std::string((const char*)arr.pData_, 32) << "\n";
|
|
|
|
|
#endif
|
|
|
|
@ -360,7 +360,7 @@ namespace Exiv2 {
|
|
|
|
|
#endif
|
|
|
|
|
xmpPacket = xmpPacket.substr(idx);
|
|
|
|
|
}
|
|
|
|
|
if (XmpParser::decode(pImage->xmpData(), xmpPacket))
|
|
|
|
|
if (XmpParser::decode(pImage->xmpData(), xmpPacket))
|
|
|
|
|
{
|
|
|
|
|
#ifndef SUPPRESS_WARNINGS
|
|
|
|
|
std::cerr << "Warning: Failed to decode XMP metadata.\n";
|
|
|
|
@ -387,7 +387,7 @@ namespace Exiv2 {
|
|
|
|
|
#endif
|
|
|
|
|
xmpPacket = xmpPacket.substr(idx);
|
|
|
|
|
}
|
|
|
|
|
if (XmpParser::decode(pImage->xmpData(), xmpPacket))
|
|
|
|
|
if (XmpParser::decode(pImage->xmpData(), xmpPacket))
|
|
|
|
|
{
|
|
|
|
|
#ifndef SUPPRESS_WARNINGS
|
|
|
|
|
std::cerr << "Warning: Failed to decode XMP metadata.\n";
|
|
|
|
@ -489,8 +489,8 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
} // PngChunk::readRawProfile
|
|
|
|
|
|
|
|
|
|
void PngChunk::zlibUncompress(const byte* compressedText,
|
|
|
|
|
unsigned int compressedTextSize,
|
|
|
|
|
void PngChunk::zlibUncompress(const byte* compressedText,
|
|
|
|
|
unsigned int compressedTextSize,
|
|
|
|
|
DataBuf& arr)
|
|
|
|
|
{
|
|
|
|
|
uLongf uncompressedLen = compressedTextSize * 2; // just a starting point
|
|
|
|
@ -534,101 +534,101 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
/* TODO : code backported from digiKam. Not yet adapted and used.
|
|
|
|
|
|
|
|
|
|
void PngChunk::writeRawProfile(png_struct *ping,
|
|
|
|
|
png_info* ping_info,
|
|
|
|
|
char* profile_type,
|
|
|
|
|
char* profile_data,
|
|
|
|
|
void PngChunk::writeRawProfile(png_struct *ping,
|
|
|
|
|
png_info* ping_info,
|
|
|
|
|
char* profile_type,
|
|
|
|
|
char* profile_data,
|
|
|
|
|
png_uint_32 length)
|
|
|
|
|
{
|
|
|
|
|
png_textp text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
register long i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uchar *sp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
png_charp dp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
png_uint_32 allocated_length, description_length;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const uchar hex[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DDebug() << "Writing Raw profile: type=" << profile_type << ", length=" << length << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text = (png_textp) png_malloc(ping, (png_uint_32) sizeof(png_text));
|
|
|
|
|
description_length = std::strlen((const char *) profile_type);
|
|
|
|
|
allocated_length = (png_uint_32) (length*2 + (length >> 5) + 20 + description_length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text[0].text = (png_charp) png_malloc(ping, allocated_length);
|
|
|
|
|
text[0].key = (png_charp) png_malloc(ping, (png_uint_32) 80);
|
|
|
|
|
text[0].key[0] = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
concatenateString(text[0].key, "Raw profile type ", 4096);
|
|
|
|
|
concatenateString(text[0].key, (const char *) profile_type, 62);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sp = (uchar*)profile_data;
|
|
|
|
|
dp = text[0].text;
|
|
|
|
|
*dp++='\n';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
copyString(dp, (const char *) profile_type, allocated_length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dp += description_length;
|
|
|
|
|
*dp++='\n';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formatString(dp, allocated_length-strlen(text[0].text), "%8lu ", length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dp += 8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i=0; i < (long) length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i%36 == 0)
|
|
|
|
|
*dp++='\n';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*(dp++)=(char) hex[((*sp >> 4) & 0x0f)];
|
|
|
|
|
*(dp++)=(char) hex[((*sp++ ) & 0x0f)];
|
|
|
|
|
*(dp++)=(char) hex[((*sp++ ) & 0x0f)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*dp++='\n';
|
|
|
|
|
*dp='\0';
|
|
|
|
|
text[0].text_length = (png_size_t) (dp-text[0].text);
|
|
|
|
|
text[0].compression = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (text[0].text_length <= allocated_length)
|
|
|
|
|
png_set_text(ping, ping_info,text, 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
png_free(ping, text[0].text);
|
|
|
|
|
png_free(ping, text[0].key);
|
|
|
|
|
png_free(ping, text);
|
|
|
|
|
|
|
|
|
|
} // PngChunk::writeRawProfile
|
|
|
|
|
|
|
|
|
|
size_t PngChunk::concatenateString(char* destination,
|
|
|
|
|
const char* source,
|
|
|
|
|
size_t PngChunk::concatenateString(char* destination,
|
|
|
|
|
const char* source,
|
|
|
|
|
const size_t length)
|
|
|
|
|
{
|
|
|
|
|
register char *q;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
register const char *p;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
register size_t i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !destination || !source || length == 0 )
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p = source;
|
|
|
|
|
q = destination;
|
|
|
|
|
i = length;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ((i-- != 0) && (*q != '\0'))
|
|
|
|
|
q++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count = (size_t) (q-destination);
|
|
|
|
|
i = length-count;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
return(count+strlen(p));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (*p != '\0')
|
|
|
|
|
{
|
|
|
|
|
if (i != 1)
|
|
|
|
@ -638,61 +638,61 @@ namespace Exiv2 {
|
|
|
|
|
}
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*q='\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return(count+(p-source));
|
|
|
|
|
|
|
|
|
|
} // PngChunk::concatenateString
|
|
|
|
|
|
|
|
|
|
size_t PngChunk::copyString(char* destination,
|
|
|
|
|
const char* source,
|
|
|
|
|
size_t PngChunk::copyString(char* destination,
|
|
|
|
|
const char* source,
|
|
|
|
|
const size_t length)
|
|
|
|
|
{
|
|
|
|
|
register char *q;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
register const char *p;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
register size_t i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !destination || !source || length == 0 )
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p = source;
|
|
|
|
|
q = destination;
|
|
|
|
|
i = length;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((i != 0) && (--i != 0))
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
if ((*q++=(*p++)) == '\0')
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (--i != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
|
|
|
|
if (length != 0)
|
|
|
|
|
*q='\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (*p++ != '\0');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return((size_t) (p-source-1));
|
|
|
|
|
|
|
|
|
|
} // PngChunk::copyString
|
|
|
|
|
|
|
|
|
|
long PngChunk::formatString(char* string,
|
|
|
|
|
const size_t length,
|
|
|
|
|
const char* format,
|
|
|
|
|
long PngChunk::formatString(char* string,
|
|
|
|
|
const size_t length,
|
|
|
|
|
const char* format,
|
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
long n;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
va_list operands;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
va_start(operands,format);
|
|
|
|
|
n = (long) formatStringList(string, length, format, operands);
|
|
|
|
|
va_end(operands);
|
|
|
|
@ -700,20 +700,20 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
} // PngChunk::formatString
|
|
|
|
|
|
|
|
|
|
long PngChunk::formatStringList(char* string,
|
|
|
|
|
const size_t length,
|
|
|
|
|
const char* format,
|
|
|
|
|
long PngChunk::formatStringList(char* string,
|
|
|
|
|
const size_t length,
|
|
|
|
|
const char* format,
|
|
|
|
|
va_list operands)
|
|
|
|
|
{
|
|
|
|
|
int n = vsnprintf(string, length, format, operands);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (n < 0)
|
|
|
|
|
string[length-1] = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return((long) n);
|
|
|
|
|
} // PngChunk::formatStringList
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Exiv2
|
|
|
|
|
|
|
|
|
|
// *****************************************************************************
|
|
|
|
|