Check-in [979234fb70]

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

Overview
Comment:Report False when we couldn't read the image size from a valid JPG image.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 979234fb7027b2745fef0e2d18d424af26a4fb04
User & Date: tinus 2015-02-03 13:22:48
Context
2015-02-03
13:24
Implemented several zooming features (keep proportions). Use TWICImage instead of TOleGraphic as fallback. check-in: 1d07ee6f91 user: tinus tags: trunk
13:22
Report False when we couldn't read the image size from a valid JPG image. check-in: 979234fb70 user: tinus tags: trunk
2014-12-09
17:53
Double-clicking the main form cycles the wallpapers. check-in: 736f8b1959 user: tinus tags: trunk
Changes

Changes to src/ImgSize.pas.

65
66
67
68
69
70
71

72
73
74
75
76
77
78
..
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
  Sig: array[0..1] of byte;
  x: integer;
  Seg: byte;
  Dummy: array[0..15] of byte;
  Len: word;
  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
................................................................................
    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;







>







 







|


>
>







 







<
<
<







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
..
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
  Sig: array[0..1] of byte;
  x: integer;
  Seg: byte;
  Dummy: array[0..15] of byte;
  Len: word;
  ReadLen: LongInt;
begin
  Result := False;
  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
................................................................................
    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);
          Result := True;
          Exit;
        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;
end;


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