> 1. Load all data to Stream A
> 2. Copy part of A to B
> 3. Write Additional info to B
> 4. Write remainder of A to B
> ...is correct if there are no internal references to files
> locations... Does JPEG use
> a directory of tags or are tags always read sequentially with a
> tag-length stored at
> the beginning of each (along with tag-type I assume)...
JPEG uses 2-byte header information:
header (2 bytes):  $ff, $d8 (SOI) (these two identify a JPEG/JFIF file)
any number of "segments" (similar to IFF chunks)
trailer (2 bytes): $ff, $d9 (EOI)

Segment format: ~~~~~~~~~~~~~~~
header (4 bytes):        $ff     identifies segment         n      type of
segment (one byte)        sh, sl  size of the segment, including these two
bytes, but not                including the $ff and the type byte. Note, not
Intel order:                high byte first, low byte last!   - contents of
the segment, max. 65533 bytes.

So what you do is set up the start bytes then insert $FF $FE(comment), bytes
of comment, $FF $C0, replicate the header information up to the SOFrame
header bytes($FF $C0),graphic information...



QUESTION
BTW, you cant free a memorystream at the end of a function, if u want the
stream passed back as a result. But does the memorystream get released/freed
automatically after the function has returned??

EG
I call the function like so:
thememstream:=jpgcomment.writecommenttostream(thememstream);

//external function:
function tjpgcomment.writecommenttostream(oldS:
TMemoryStream):TMemoryStream;
//This is OK
  newS.CopyFrom(oldS,(i));
  Result:=newS;
end;

//This is not OK, as the result is destroyed before it reaches the caller
  newS.CopyFrom(oldS,(i));
  Result:=newS;
  newS.free;
end;

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to