From: <na...@us...> - 2006-02-28 08:48:48
|
Revision: 633 Author: nandod Date: 2006-02-28 00:48:40 -0800 (Tue, 28 Feb 2006) ViewCVS: http://svn.sourceforge.net/instantobjects?rev=633&view=rev Log Message: ----------- cosmetic fixes Modified Paths: -------------- trunk/Source/Core/InstantPersistence.pas Modified: trunk/Source/Core/InstantPersistence.pas =================================================================== --- trunk/Source/Core/InstantPersistence.pas 2006-02-28 03:06:41 UTC (rev 632) +++ trunk/Source/Core/InstantPersistence.pas 2006-02-28 08:48:40 UTC (rev 633) @@ -3092,58 +3092,54 @@ SizeOfGraphicHeader = 8; MinimumBytesToRead = 10; var - P: PChar; + P: array [0..MinimumBytesToRead - 1] of Char; StreamLength: Longint; BytesRetrieved: Integer; begin Result := gffUnknown; if not Assigned(AStream) then Exit; - GetMem(P, 10); - try - StreamLength := AStream.Size; - AStream.Position := 0; - BytesRetrieved := AStream.Read(P[0], MinimumBytesToRead); - AStream.Position := 0; - if BytesRetrieved < MinimumBytesToRead then - Exit; - // bitmap format - if (P[0] = #66) and (P[1] = #77) then - Result := gffBmp - // tiff format - else if ((P[0] = #73) and (P[1] = #73) and (P[2] = #42) and (P[3] = #0)) - or ((P[0] = #77) and (P[1] = #77) and (P[2] = #42) and (P[3] = #0)) then - Result := gffTiff - // jpg format - else if (P[6] = #74) and (P[7] = #70) and (P[8] = #73) and (P[9] = #70) - or (P[6] = #69) and (P[7] = #120) and (P[8] = #105) and (P[9] = #102) then - Result := gffJpeg - // png format - else if (P[0] = #137 ) and (P[1] = #80) and (P[2] = #78) and (P[3] = #71) - and (P[4] = #13) and (P[5] = #10) and (P[6] = #26) and (P[7] = #10) then - Result := gffPng - // dcx format - else if (P[0] = #177) and (P[1] = #104) and (P[2] = #222) and (P[3] = #58) then - Result := gffDcx - // pcx format - else if p[0] = #10 then - Result := gffPcx - // emf format - else if ((P[0] = #215) and (P[1] = #205) and (P[2] = #198) and (P[3] = #154)) - or ((P[0] = #1) and (P[1] = #0) and (P[2] = #0) and (P[3] = #0)) then - Result := gffEmf - // gif format - else if (P[0] = #$47) and (P[1] = #$49) and (P[2] = #$46) then - Result := gffGif - // bitmap format with TGraphicHeader header - else if (P[0] = #01) and (P[1] = #00) and (P[2] = #00) and (P[3] = #01) - and (PLongint(@p[4])^ = StreamLength - SizeOfGraphicHeader) then - begin - Result := gffBmp; - AStream.Position := SizeOfGraphicHeader; - end; - finally - FreeMem(P); + StreamLength := AStream.Size; + AStream.Position := 0; + FillChar(P, SizeOf(P), #0); + BytesRetrieved := AStream.Read(P[0], SizeOf(P)); + AStream.Position := 0; + if BytesRetrieved < MinimumBytesToRead then + Exit; + // bitmap format + if (P[0] = #66) and (P[1] = #77) then + Result := gffBmp + // tiff format + else if ((P[0] = #73) and (P[1] = #73) and (P[2] = #42) and (P[3] = #0)) + or ((P[0] = #77) and (P[1] = #77) and (P[2] = #42) and (P[3] = #0)) then + Result := gffTiff + // jpg format + else if (P[6] = #74) and (P[7] = #70) and (P[8] = #73) and (P[9] = #70) + or (P[6] = #69) and (P[7] = #120) and (P[8] = #105) and (P[9] = #102) then + Result := gffJpeg + // png format + else if (P[0] = #137 ) and (P[1] = #80) and (P[2] = #78) and (P[3] = #71) + and (P[4] = #13) and (P[5] = #10) and (P[6] = #26) and (P[7] = #10) then + Result := gffPng + // dcx format + else if (P[0] = #177) and (P[1] = #104) and (P[2] = #222) and (P[3] = #58) then + Result := gffDcx + // pcx format + else if p[0] = #10 then + Result := gffPcx + // emf format + else if ((P[0] = #215) and (P[1] = #205) and (P[2] = #198) and (P[3] = #154)) + or ((P[0] = #1) and (P[1] = #0) and (P[2] = #0) and (P[3] = #0)) then + Result := gffEmf + // gif format + else if (P[0] = #$47) and (P[1] = #$49) and (P[2] = #$46) then + Result := gffGif + // bitmap format with TGraphicHeader header + else if (P[0] = #01) and (P[1] = #00) and (P[2] = #00) and (P[3] = #01) + and (PLongint(@p[4])^ = StreamLength - SizeOfGraphicHeader) then + begin + Result := gffBmp; + AStream.Position := SizeOfGraphicHeader; end; end; |