| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //
- // The graphics engine GLScene https://github.com/glscene
- //
- unit Formats.HDRImage;
- (*
- Good for preview picture in OpenDialog,
- so you may include both HDRImage (preview) and GLFileHDR (loading)
- *)
- interface
- {$I GLScene.Defines.inc}
- uses
- Winapi.Windows,
- System.Classes,
- System.SysUtils,
- Vcl.Graphics,
- GLScene.VectorTypes,
- GLScene.OpenGLTokens,
- GLScene.VectorGeometry,
- GLScene.TextureFormat,
- GLS.FileHDR;
- type
- THDRImage = class(TBitmap)
- public
- procedure LoadFromStream(stream: TStream); override;
- procedure SaveToStream(stream: TStream); override;
- end;
- implementation //------------------------------------------------------------
- // ------------------
- // ------------------ THDRImage ------------------
- // ------------------
- procedure THDRImage.LoadFromStream(stream: TStream);
- var
- FullHDR: TGLHDRImage;
- src, dst: PGLubyte;
- y: integer;
- begin
- FullHDR := TGLHDRImage.Create;
- try
- FullHDR.LoadFromStream(stream);
- except
- FullHDR.Free;
- raise;
- end;
- FullHDR.Narrow;
- Width := FullHDR.LevelWidth[0];
- Height := FullHDR.LevelHeight[0];
- Transparent := false;
- PixelFormat := pf32bit;
- src := PGLubyte(FullHDR.Data);
- for y := 0 to Height - 1 do
- begin
- dst := ScanLine[Height - 1 - y];
- Move(src^, dst^, Width * 4);
- Inc(src, Width * 4);
- end;
- FullHDR.Free;
- end;
- procedure THDRImage.SaveToStream(stream: TStream);
- begin
- Assert(False, 'Not supported');
- end;
- initialization // ------------------------------------------------------------
- TPicture.RegisterFileFormat('HDR', 'High Dynamic Range Image', THDRImage);
- finalization // --------------------------------------------------------------
- TPicture.UnregisterGraphicClass(THDRImage);
- end.
|