/
stud_22-365
/
GLXEngine
Обзор
Документация
Войти
/
stud_22-365
/
GLXEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v2.0
Source/FormatHDRImage.pas
95 строк
2 KB
GLScene
Updated v.2.0 for Delphi/C++Builder
09 авг 2020, 23:03
09 авг 2020, 23:03
0538f8f
Код
Авторство
О чём код?
// // This unit is part of the GLScene Engine, http://glscene.org // unit FormatHDRImage; (* Good for preview picture in OpenDialog, so you may include both HDRImage (preview) and GLFileHDR (loading) *) interface {$I GLScene.inc} uses Winapi.Windows, System.Classes, System.SysUtils, Vcl.Graphics, GLS.OpenGLTokens, GLS.VectorGeometry, GLS.Graphics; type THDRImage = class(TBitmap) public procedure LoadFromStream(stream: TStream); override; procedure SaveToStream(stream: TStream); override; end; //-------------------------------------------------------------------- implementation //-------------------------------------------------------------------- uses GLS.FileHDR, GLS.TextureFormat; // ------------------ // ------------------ 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.