home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 November / CDVD1105.ISO / Software / Freeware / programare / graphics32 / Examples / Clx / Image32_Ex / MainUnit.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2004-07-16  |  2.4 KB  |  90 lines

  1. unit MainUnit;
  2.  
  3. (* ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is Graphics32
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Alex A. Denisov
  20.  *
  21.  * Portions created by the Initial Developer are Copyright (C) 2000-2004
  22.  * the Initial Developer. All Rights Reserved.
  23.  *
  24.  * Contributor(s):
  25.  *
  26.  * ***** END LICENSE BLOCK ***** *)
  27.  
  28. interface
  29.  
  30. uses
  31.   SysUtils, Classes, QGraphics, QControls, QForms, QDialogs,
  32.   QStdCtrls, QExtCtrls, GR32, GR32_Image, GR32_RangeBars;
  33.  
  34. type
  35.   TForm1 = class(TForm)
  36.     Panel1: TPanel;
  37.     Panel2: TPanel;
  38.     Image: TImage32;
  39.     rgScaleMode: TRadioGroup;
  40.     rgStretchFilter: TRadioGroup;
  41.     rgBitmapAlign: TRadioGroup;
  42.     sbScale: TGaugeBar;
  43.     Label1: TLabel;
  44.     procedure rgBitmapAlignClick(Sender: TObject);
  45.     procedure sbScaleChange(Sender: TObject);
  46.     procedure rgScaleModeClick(Sender: TObject);
  47.     procedure rgStretchFilterClick(Sender: TObject);
  48.   public
  49.     Time: Single;
  50.   end;
  51.  
  52. var
  53.   Form1: TForm1;
  54.  
  55. implementation
  56.  
  57. {$R *.xfm}
  58.  
  59. procedure TForm1.rgBitmapAlignClick(Sender: TObject);
  60. const
  61.   BA_CONSTS: array [0..2] of TBitmapAlign = (baTopLeft, baCenter, baTile);
  62. begin
  63.   Image.BitmapAlign := BA_CONSTS[rgBitmapAlign.ItemIndex];
  64. end;
  65.  
  66. procedure TForm1.sbScaleChange(Sender: TObject);
  67. begin
  68.   sbScale.Update;
  69.   Image.Scale := sbScale.Position / 100;
  70. end;
  71.  
  72. procedure TForm1.rgScaleModeClick(Sender: TObject);
  73. const
  74.   SM_CONSTS: array [0..3] of TScaleMode = (smNormal, smStretch, smScale, smResize);
  75. begin
  76.   Image.ScaleMode := SM_CONSTS[rgScaleMode.ItemIndex];
  77.   sbScale.Enabled := rgScaleMode.ItemIndex = 2;
  78.   Label1.Enabled := rgScaleMode.ItemIndex = 2;
  79. end;
  80.  
  81. procedure TForm1.rgStretchFilterClick(Sender: TObject);
  82. const
  83.   SF_CONSTS: array [0..5] of TStretchFilter =
  84.     (sfNearest, sfLinear, sfCosine, sfSpline, sfLanczos, sfMitchell);
  85. begin
  86.   Image.Bitmap.StretchFilter := SF_CONSTS[rgStretchFilter.ItemIndex];
  87. end;
  88.  
  89. end.
  90.