Line | |
---|
1 | unit BGRAReadJpeg;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FPReadJPEG;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TJPEGScale = FPReadJPEG.TJPEGScale;
|
---|
12 | TJPEGReadPerformance = FPReadJPEG.TJPEGReadPerformance;
|
---|
13 |
|
---|
14 | const
|
---|
15 | jsFullSize = FPReadJPEG.jsFullSize;
|
---|
16 | jsHalf = FPReadJPEG.jsHalf;
|
---|
17 | jsQuarter = FPReadJPEG.jsQuarter;
|
---|
18 | jsEighth = FPReadJPEG.jsEighth;
|
---|
19 |
|
---|
20 | jpBestQuality = FPReadJPEG.jpBestQuality;
|
---|
21 | jpBestSpeed = FPReadJPEG.jpBestSpeed;
|
---|
22 |
|
---|
23 | type
|
---|
24 | { TBGRAReaderJpeg }
|
---|
25 |
|
---|
26 | TBGRAReaderJpeg = class(TFPReaderJPEG)
|
---|
27 | constructor Create; override;
|
---|
28 | protected
|
---|
29 | function InternalCheck(Str: TStream): boolean; override;
|
---|
30 | end;
|
---|
31 |
|
---|
32 | implementation
|
---|
33 |
|
---|
34 | uses BGRABitmapTypes;
|
---|
35 |
|
---|
36 | { TBGRAReaderJpeg }
|
---|
37 |
|
---|
38 | constructor TBGRAReaderJpeg.Create;
|
---|
39 | begin
|
---|
40 | inherited Create;
|
---|
41 | Performance := jpBestQuality;
|
---|
42 | end;
|
---|
43 |
|
---|
44 | function TBGRAReaderJpeg.InternalCheck(Str: TStream): boolean;
|
---|
45 | var {%H-}magic: packed array[0..3] of byte;
|
---|
46 | OldPos,BytesRead:int64;
|
---|
47 | begin
|
---|
48 | Result:=false;
|
---|
49 | if Str=nil then exit;
|
---|
50 | OldPos:= str.Position;
|
---|
51 | BytesRead := str.Read({%H-}magic,sizeof(magic));
|
---|
52 | str.Position:=OldPos;
|
---|
53 | if BytesRead<>sizeof(magic) then exit;
|
---|
54 | if (magic[0] = $ff) and (magic[1] = $d8) and (magic[2] = $ff) and (magic[3] >= $c0) then result := true;
|
---|
55 | end;
|
---|
56 |
|
---|
57 | initialization
|
---|
58 |
|
---|
59 | DefaultBGRAImageReader[ifJpeg] := TBGRAReaderJpeg;
|
---|
60 |
|
---|
61 | end.
|
---|
62 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.