www.pudn.com > yrsCapture.zip > Resize.pas
{******************************************************************************}
{* *}
{* Adirondack Software & Graphics Resize Unit *}
{* (C) Copyright Adirondack Software & Graphics 1996-1998 *}
{* *}
{******************************************************************************}
unit Resize;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, Buttons,
ExtCtrls, ComCtrls, JPEG, NetGradient;
type
TResizeDlg = class( TForm )
OKBtn: TButton;
CancelBtn: TButton;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
GroupBox2: TGroupBox;
Label3: TLabel;
Label4: TLabel;
Panel1: TPanel;
Panel2: TPanel;
Splitter1: TSplitter;
Panel3: TPanel;
Image1: TImage;
Image2: TImage;
NetGradient1: TNetGradient;
TrackBar1: TTrackBar;
TrackBar2: TTrackBar;
procedure TrackBar1Change( Sender: TObject );
procedure TrackBar2Change( Sender: TObject );
procedure FormShow( Sender: TObject );
private
{ Private declarations }
public
{ Public declarations }
end;
var
ResizeDlg: TResizeDlg;
implementation
Uses Imagesize;
{$R *.DFM}
{==============================================================================}
procedure TResizeDlg.TrackBar1Change( Sender: TObject );
{==============================================================================}
var
Bitmap: TBitmap;
Temp: Boolean;
TJPG: TJPEGImage;
begin
{ Here you want to set up a new bitmap with the proper proportions for your
zoom factor and draw the image you want zoomed into it. }
// is image jpeg
Temp := Image1.Picture.Graphic is TJPEGImage;
if Temp then begin
Label3.Caption := 'Width: '+IntToStr( Trackbar1.Position );
Bitmap := TBitmap.Create;
TJPG := TJPEGImage.Create;
Bitmap.Width := TrackBar1.Position; { insert your zoomed width here }
Bitmap.Height := TrackBar2.Position; { insert your zoomed height here}
Bitmap.Canvas.StretchDraw( Bitmap.Canvas.ClipRect,Image1.Picture.Bitmap );
{ Here you assign the new bitmap to the graphic property of the image box.
The image box will automatically dispose of the resources used by its
prior image. }
// Assign jpeg a bitmap
TJPG.Assign(Bitmap);
Image2.Picture.Graphic := Bitmap;
Image2.Invalidate;
Bitmap.Free;
TJPG.Free;
end
else
begin
Label3.Caption := 'Width: '+IntToStr( Trackbar1.Position );
Bitmap := TBitmap.Create;
Bitmap.Width := TrackBar1.Position; { insert your zoomed width here }
Bitmap.Height := TrackBar2.Position; { insert your zoomed height here}
Bitmap.Canvas.StretchDraw( Bitmap.Canvas.ClipRect,Image1.Picture.Bitmap );
{ Here you assign the new bitmap to the graphic property of the image box.
The image box will automatically dispose of the resources used by its
prior image. }
Image2.Picture.Graphic := Bitmap;
Image2.Invalidate;
Bitmap.Free;
// TJPG.Free;
end;
Image1.Hint := IntToStr( Image1.Picture.Height )+
' x '+ IntToStr( Image1.Picture.Width )+
'|'+ IntToStr( Image1.Picture.Bitmap.Width )+' pixels x '+IntToStr( Image1.Picture.Bitmap.Height )+' pixels';
Image2.Hint := IntToStr( Image2.Picture.Height )+
' x '+ IntToStr( Image2.Picture.Width )+
'|'+ IntToStr( Image2.Picture.Bitmap.Width )+' pixels x '+IntToStr( Image2.Picture.Bitmap.Height )+' pixels';
end;
{==============================================================================}
procedure TResizeDlg.TrackBar2Change( Sender: TObject );
{==============================================================================}
var
Bitmap: TBitmap;
begin
{ Here you want to set up a new bitmap with the proper proportions for your
zoom factor and draw the image you want zoomed into it. }
Label4.Caption := 'Height: '+IntToStr( Trackbar2.Position );
Bitmap := TBitmap.Create;
Bitmap.Width := TrackBar1.Position; { insert your zoomed width here }
Bitmap.Height := TrackBar2.Position; { insert your zoomed height here}
Bitmap.Canvas.StretchDraw( Bitmap.Canvas.ClipRect,Image1.Picture.Bitmap );
{ Here you assign the new bitmap to the graphic property of the image box.
The image box will automatically dispose of the resources used by its
prior image. }
Image2.Picture.Graphic := Bitmap;
Image2.Invalidate;
Bitmap.Free;
Image1.Hint := IntToStr( Image1.Picture.Height )+
' x '+ IntToStr( Image1.Picture.Width )+
'|'+ IntToStr( Image1.Picture.Bitmap.Width )+' pixels x '+IntToStr( Image1.Picture.Bitmap.Height )+' pixels';
Image2.Hint := IntToStr( Image2.Picture.Height )+
' x '+ IntToStr( Image2.Picture.Width )+
'|'+ IntToStr( Image2.Picture.Bitmap.Width )+' pixels x '+IntToStr( Image2.Picture.Bitmap.Height )+' pixels';
end;
{==============================================================================}
procedure TResizeDlg.FormShow( Sender: TObject );
{==============================================================================}
begin
ResizeDlg.TrackBar1.Position := Image1.Picture.Width;
ResizeDlg.TrackBar2.Position := Image1.Picture.Height;
Label3.Caption := 'Width: ' + IntToStr( ResizeDlg.TrackBar1.Position );
Label4.Caption := 'Height: ' + IntToStr( ResizeDlg.TrackBar2.Position );
end;
end.