RGBALoaderUnit.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. unit RGBALoaderUnit;
  2. (* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is Graphics32
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Alex A. Denisov
  19. *
  20. * Portions created by the Initial Developer are Copyright (C) 2000-2004
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. *
  25. * ***** END LICENSE BLOCK ***** *)
  26. interface
  27. {$IFDEF FPC}
  28. {$MODE Delphi}
  29. {$ENDIF}
  30. {$IFNDEF FPC}
  31. {$DEFINE Windows}
  32. {$ENDIF}
  33. uses
  34. {$IFDEF FPC}LCLIntf, LResources, {$ENDIF}
  35. SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
  36. GR32_Image, GR32_Filters, GR32_RangeBars, ExtCtrls, ExtDlgs, Buttons;
  37. type
  38. TRGBALoaderForm = class(TForm)
  39. Bevel1: TBevel;
  40. BtnCancel: TButton;
  41. BtnLoadAlpha: TButton;
  42. BtnLoadImage: TButton;
  43. BtnOK: TButton;
  44. BtnResetScales: TButton;
  45. ImgAlpha: TImgView32;
  46. ImgRGB: TImgView32;
  47. LblAlphaImage: TLabel;
  48. LblInfo: TLabel;
  49. LblNote: TLabel;
  50. LblRGBImage: TLabel;
  51. OpenPictureDialog: TOpenPictureDialog;
  52. PnlInfo: TPanel;
  53. BtnZoomInImage: TSpeedButton;
  54. BtnZoomOutImage: TSpeedButton;
  55. BtnZoomInAlpha: TSpeedButton;
  56. BtnZoomOutAlpha: TSpeedButton;
  57. procedure BtnLoadImageClick(Sender: TObject);
  58. procedure BtnLoadAlphaClick(Sender: TObject);
  59. procedure BtnZoomInImageClick(Sender: TObject);
  60. procedure BtnZoomOutImageClick(Sender: TObject);
  61. procedure BtnZoomInAlphaClick(Sender: TObject);
  62. procedure BtnZoomOutAlphaClick(Sender: TObject);
  63. procedure BtnResetScalesClick(Sender: TObject);
  64. end;
  65. var
  66. RGBALoaderForm: TRGBALoaderForm;
  67. implementation
  68. {$R *.dfm}
  69. { TRGBALoaderForm }
  70. procedure TRGBALoaderForm.BtnLoadImageClick(Sender: TObject);
  71. begin
  72. with OpenPictureDialog do
  73. if Execute then ImgRGB.Bitmap.LoadFromFile(FileName);
  74. end;
  75. procedure TRGBALoaderForm.BtnLoadAlphaClick(Sender: TObject);
  76. begin
  77. with OpenPictureDialog, ImgAlpha do
  78. if Execute then
  79. begin
  80. Bitmap.LoadFromFile(FileName);
  81. ColorToGrayscale(Bitmap, Bitmap);
  82. end;
  83. end;
  84. procedure TRGBALoaderForm.BtnZoomInImageClick(Sender: TObject);
  85. begin
  86. ImgRGB.Scale := ImgRGB.Scale * 1.5;
  87. end;
  88. procedure TRGBALoaderForm.BtnZoomOutImageClick(Sender: TObject);
  89. begin
  90. ImgRGB.Scale := ImgRGB.Scale / 1.5;
  91. end;
  92. procedure TRGBALoaderForm.BtnZoomInAlphaClick(Sender: TObject);
  93. begin
  94. ImgAlpha.Scale := ImgAlpha.Scale * 1.5;
  95. end;
  96. procedure TRGBALoaderForm.BtnZoomOutAlphaClick(Sender: TObject);
  97. begin
  98. ImgAlpha.Scale := ImgAlpha.Scale / 1.5;
  99. end;
  100. procedure TRGBALoaderForm.BtnResetScalesClick(Sender: TObject);
  101. begin
  102. ImgRGB.Scale := 1;
  103. ImgAlpha.Scale := 1;
  104. end;
  105. end.