source: trunk/Packages/bgrabitmap/bgrareadjpeg.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 1.2 KB
Line 
1unit BGRAReadJpeg;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FPReadJPEG;
9
10type
11 TJPEGScale = FPReadJPEG.TJPEGScale;
12 TJPEGReadPerformance = FPReadJPEG.TJPEGReadPerformance;
13
14const
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
23type
24 { TBGRAReaderJpeg }
25
26 TBGRAReaderJpeg = class(TFPReaderJPEG)
27 constructor Create; override;
28 protected
29 function InternalCheck(Str: TStream): boolean; override;
30 end;
31
32implementation
33
34uses BGRABitmapTypes;
35
36{ TBGRAReaderJpeg }
37
38constructor TBGRAReaderJpeg.Create;
39begin
40 inherited Create;
41 Performance := jpBestQuality;
42end;
43
44function TBGRAReaderJpeg.InternalCheck(Str: TStream): boolean;
45var {%H-}magic: packed array[0..3] of byte;
46 OldPos,BytesRead:int64;
47begin
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;
55end;
56
57initialization
58
59 DefaultBGRAImageReader[ifJpeg] := TBGRAReaderJpeg;
60
61end.
62
Note: See TracBrowser for help on using the repository browser.