void dng_jpeg_preview::SpoolAdobeThumbnail (dng_stream &stream) const { DNG_ASSERT (fCompressedData.Get (), "SpoolAdobeThumbnail: no data"); DNG_ASSERT (fPhotometricInterpretation == piYCbCr, "SpoolAdobeThumbnail: Non-YCbCr"); uint32 compressedSize = fCompressedData->LogicalSize (); stream.Put_uint32 (DNG_CHAR4 ('8','B','I','M')); stream.Put_uint16 (1036); stream.Put_uint16 (0); stream.Put_uint32 (compressedSize + 28); uint32 widthBytes = (fPreviewSize.h * 24 + 31) / 32 * 4; stream.Put_uint32 (1); stream.Put_uint32 (fPreviewSize.h); stream.Put_uint32 (fPreviewSize.v); stream.Put_uint32 (widthBytes); stream.Put_uint32 (widthBytes * fPreviewSize.v); stream.Put_uint32 (compressedSize); stream.Put_uint16 (24); stream.Put_uint16 (1); stream.Put (fCompressedData->Buffer (), compressedSize); if (compressedSize & 1) { stream.Put_uint8 (0); } }
void dng_opcode_MapTable::PutData (dng_stream &stream) const { stream.Put_uint32 (dng_area_spec::kDataSize + 4 + fCount * 2); fAreaSpec.PutData (stream); stream.Put_uint32 (fCount); uint16 *table = fTable->Buffer_uint16 (); for (uint32 index = 0; index < fCount; index++) { stream.Put_uint16 (table [index]); } }
void dng_iptc::SpoolString (dng_stream &stream, const dng_string &s, uint8 dataSet, uint32 maxChars, CharSet charSet) { if (s.IsEmpty ()) { return; } stream.Put_uint16 (0x1C02); stream.Put_uint8 (dataSet); dng_string ss (s); ss.SetLineEndingsToReturns (); if (charSet == kCharSetUTF8) { // UTF-8 encoding. if (ss.Length () > maxChars) { ss.Truncate (maxChars); } uint32 len = ss.Length (); stream.Put_uint16 ((uint16) len); stream.Put (ss.Get (), len); } else { // System character set encoding. dng_memory_data buffer; uint32 len = ss.Get_SystemEncoding (buffer); if (len > maxChars) { uint32 lower = 0; uint32 upper = ss.Length () - 1; while (upper > lower) { uint32 middle = (upper + lower + 1) >> 1; dng_string sss (ss); sss.Truncate (middle); len = sss.Get_SystemEncoding (buffer); if (len <= maxChars) { lower = middle; } else { upper = middle - 1; } } ss.Truncate (lower); len = ss.Get_SystemEncoding (buffer); } stream.Put_uint16 ((uint16) len); stream.Put (buffer.Buffer_char (), len); }