Check-in [7293616336]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:GetJPGSize now returns False when it's not a JPG.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7293616336d3ae0d31936479cf0684871ea45ad6
User & Date: tinus 2014-12-09 17:52:40
Context
2014-12-09
17:53
Double-clicking the main form cycles the wallpapers. check-in: 736f8b1959 user: tinus tags: trunk
17:52
GetJPGSize now returns False when it's not a JPG. check-in: 7293616336 user: tinus tags: trunk
2014-12-08
20:21
Added proper icon. Version 2.0. Cleaned up project file. check-in: a2129fa999 user: tinus tags: trunk
Changes

Changes to src/ImgSize.pas.

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105



106
107
108
109
110
111
112
  ReadLen: LongInt;
begin
  FillChar(Sig, SizeOf(Sig), #0);
  ReadLen := Stream.Read(Sig[0], SizeOf(Sig));
  for x := Low(Sig) to High(Sig) do
    if Sig[x] <> ValidSig[x] then
      ReadLen := 0;
    if ReadLen > 0 then
    begin
      ReadLen := Stream.Read(Seg, 1);
      while (Seg = $FF) and (ReadLen > 0) do
      begin
        ReadLen := Stream.Read(Seg, 1);
        if Seg <> $FF then
        begin
          if (Seg = $C0) or (Seg = $C1) then
          begin
            ReadLen := Stream.Read(Dummy[0], 3);  // don't need these bytes
            wHeight := ReadMWord(Stream);
            wWidth := ReadMWord(Stream);
          end
          else
          begin
            if not (Seg in Parameterless) then
            begin
              Len := ReadMWord(Stream);
              Stream.Seek(Len - 2, 1);
              Stream.Read(Seg, 1);
            end
            else
              Seg := $FF;  // Fake it to keep looping.
          end;
        end;
      end;
    end;
  Result := True; // TODO: fail if we run into strange stuff?



end;


function GetPNGSize(const sFile: string; out wWidth, wHeight: word): boolean;
var
  FS: TFileStream;
begin







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<



|
>
>
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
  ReadLen: LongInt;
begin
  FillChar(Sig, SizeOf(Sig), #0);
  ReadLen := Stream.Read(Sig[0], SizeOf(Sig));
  for x := Low(Sig) to High(Sig) do
    if Sig[x] <> ValidSig[x] then
      ReadLen := 0;
  if ReadLen > 0 then
  begin
    ReadLen := Stream.Read(Seg, 1);
    while (Seg = $FF) and (ReadLen > 0) do
    begin
      ReadLen := Stream.Read(Seg, 1);
      if Seg <> $FF then
      begin
        if (Seg = $C0) or (Seg = $C1) then
        begin
          ReadLen := Stream.Read(Dummy[0], 3);  // don't need these bytes
          wHeight := ReadMWord(Stream);
          wWidth := ReadMWord(Stream);
        end
        else
        begin
          if not (Seg in Parameterless) then
          begin
            Len := ReadMWord(Stream);
            Stream.Seek(Len - 2, 1);
            Stream.Read(Seg, 1);
          end
          else
            Seg := $FF;  // Fake it to keep looping.

        end;
      end;
    end;
    Result := True; // TODO: fail if we run into strange stuff?
  end else begin
    Result := False;
  end;
end;


function GetPNGSize(const sFile: string; out wWidth, wHeight: word): boolean;
var
  FS: TFileStream;
begin