2
0

Formatx.HDRImage.pas 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // The graphics engine GLXEngine. The unit of GXScene for Delphi
  3. //
  4. unit Formatx.HDRImage;
  5. (*
  6. Good for preview picture in OpenDialog,
  7. so you may include both HDRImage (preview) and GLFileHDR (loading)
  8. *)
  9. interface
  10. {$I Stage.Defines.inc}
  11. uses
  12. Winapi.OpenGL,
  13. Winapi.Windows,
  14. System.Classes,
  15. System.SysUtils,
  16. FMX.Graphics,
  17. Stage.VectorGeometry,
  18. GXS.Graphics;
  19. type
  20. THDRImage = class(TBitmap)
  21. public
  22. { TODO : E2170 Cannot override a non-virtual method }
  23. procedure LoadFromStream(stream: TStream); //in VCL override;
  24. procedure SaveToStream(stream: TStream); //in VCL override;
  25. end;
  26. //============================================================================
  27. implementation
  28. //============================================================================
  29. uses
  30. GXS.FileHDR,
  31. Stage.TextureFormat;
  32. // ------------------
  33. // ------------------ THDRImage ------------------
  34. // ------------------
  35. procedure THDRImage.LoadFromStream(stream: TStream);
  36. var
  37. FullHDR: TgxHDRImage;
  38. src, dst: PGLubyte;
  39. y: integer;
  40. begin
  41. FullHDR := TgxHDRImage.Create;
  42. try
  43. FullHDR.LoadFromStream(stream);
  44. except
  45. FullHDR.Free;
  46. raise;
  47. end;
  48. FullHDR.Narrow;
  49. Width := FullHDR.LevelWidth[0];
  50. Height := FullHDR.LevelHeight[0];
  51. { TODO : E2064 Left side cannot be assigned to }
  52. (*
  53. Transparent := false;
  54. PixelFormat := glpf32bit;
  55. *)
  56. src := PGLubyte(FullHDR.Data);
  57. for y := 0 to Height - 1 do
  58. begin
  59. { TODO : E2003 Undeclared identifier: 'ScanLine' }
  60. (*dst := ScanLine[Height - 1 - y];*)
  61. Move(src^, dst^, Width * 4);
  62. Inc(src, Width * 4);
  63. end;
  64. FullHDR.Free;
  65. end;
  66. procedure THDRImage.SaveToStream(stream: TStream);
  67. begin
  68. Assert(False, 'Not supported');
  69. end;
  70. // ------------------------------------------------------------------
  71. initialization
  72. // ------------------------------------------------------------------
  73. { TODO : E2003 Undeclared identifier: 'RegisterFileFormat', it needs to be added }
  74. (*TPicture.RegisterFileFormat('HDR', 'High Dynamic Range Image', THDRImage);*)
  75. // ------------------------------------------------------------------
  76. finalization
  77. // ------------------------------------------------------------------
  78. { TODO : E2003 Undeclared identifier: 'UnregisterFileFormat', it needs to be added }
  79. (*TPicture.UnregisterGraphicClass(THDRImage);*)
  80. end.