You can rotate the car in a layer and the car remains the same size regardless of the rotation angle. The actual layer grows to accommodate the car but the car dimensions is not changed.
Here is a demo:
PAS
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtDlgs, StdCtrls, ExtCtrls, imageenio, imageenproc, ieview,
imageenview;
type
TForm1 = class(TForm)
Panel1: TPanel;
Open1: TButton;
Rotate1: TButton;
ImageEnView1: TImageEnView;
ImageEnProc1: TImageEnProc;
ImageEnIO1: TImageEnIO;
OpenPictureDialog1: TOpenPictureDialog;
Save1: TButton;
SavePictureDialog1: TSavePictureDialog;
AddLayer1: TButton;
Exit1: TButton;
Merge1: TButton;
procedure Open1Click(Sender: TObject);
procedure Rotate1Click(Sender: TObject);
procedure Save1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure AddLayer1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure Merge1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses hyiedefs, hyieutils, iexhelperfunctions;
procedure TForm1.AddLayer1Click(Sender: TObject);
var
iLayer: integer;
iWidth: integer;
iHeight: integer;
begin
iLayer := ImageEnView1.LayersAdd;
{ Set IO Params }
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 4;
iWidth := ImageEnView1.IEBitmap.Width;
iHeight := ImageEnView1.IEBitmap.Height;
{ Render a transparent layer }
ImageEnView1.IEBitmap.IEInitialize(iWidth, iHeight, clBlack, True);
ImageEnView1.Update;
ImageEnView1.LayersCurrent := iLayer;
ImageEnView1.CurrentLayer.VisibleBox := True;
ImageEnView1.CurrentLayer.Selectable := True;
ImageEnView1.LayersDrawBox := True;
ImageEnView1.CurrentLayer.Locked := False;
ImageEnView1.MouseInteract := [miMoveLayers, miResizeLayers];
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
IERegisterFormats;
OpenPictureDialog1.Filter := GraphicFilter(TGraphic);
SavePictureDialog1.Filter := GraphicFilter(TGraphic);
{ Set bitmaps to handle transparency }
ImageEnView1.IO.Params.BMP_HandleTransparency := True;
ImageEnView1.LayersResizeAspectRatio := iearALTKey;
{ Allow selection of transparent layers }
ImageEnView1.SelectionOptions := ImageEnView1.SelectionOptions +
[iesoSelectTranspLayers];
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
IEUnregisterFormats;
end;
procedure TForm1.Merge1Click(Sender: TObject);
begin
ImageEnView1.LayersMergeAll;
ImageEnView1.Update;
end;
procedure TForm1.Open1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
begin
ImageEnView1.IO.LoadFromFile(OpenPictureDialog1.Filename);
ImageEnView1.Update;
end;
end;
procedure TForm1.Rotate1Click(Sender: TObject);
begin
ImageEnView1.IEBitmap.Rotate(45, True, ierBicubic, clWhite);
ImageEnView1.LayersFixRotations(ImageEnView1.LayersCurrent);
ImageEnView1.LayersFixSizes(ImageEnView1.LayersCurrent);
ImageEnView1.LayersFixBorders(ImageEnView1.LayersCurrent);
ImageEnView1.Update;
end;
procedure TForm1.Save1Click(Sender: TObject);
begin
if SavePictureDialog1.Execute then
begin
ImageEnView1.IO.SaveToFile(SavePictureDialog1.Filename);
end;
end;
end.
end.
DFM
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Rotate Layers'
ClientHeight = 299
ClientWidth = 635
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 635
Height = 41
Align = alTop
TabOrder = 0
DesignSize = (
635
41)
object Open1: TButton
Left = 11
Top = 9
Width = 75
Height = 25
Caption = 'Open'
TabOrder = 0
OnClick = Open1Click
end
object Rotate1: TButton
Left = 173
Top = 9
Width = 75
Height = 25
Caption = 'Rotate'
TabOrder = 1
OnClick = Rotate1Click
end
object Save1: TButton
Left = 335
Top = 9
Width = 75
Height = 25
Caption = 'Save'
TabOrder = 2
OnClick = Save1Click
end
object AddLayer1: TButton
Left = 92
Top = 9
Width = 75
Height = 25
Caption = 'Add Layer'
TabOrder = 3
OnClick = AddLayer1Click
end
object Exit1: TButton
Left = 545
Top = 9
Width = 75
Height = 25
Anchors = [akTop, akRight]
Caption = 'Exit'
TabOrder = 4
OnClick = Exit1Click
end
object Merge1: TButton
Left = 254
Top = 9
Width = 75
Height = 25
Caption = 'Merge'
TabOrder = 5
OnClick = Merge1Click
end
end
object ImageEnView1: TImageEnView
Left = 0
Top = 41
Width = 635
Height = 258
Background = clBtnFace
ParentCtl3D = False
EnableInteractionHints = True
Align = alClient
TabOrder = 1
end
object ImageEnProc1: TImageEnProc
PreviewsParams = [prppShowResetButton, prppHardReset]
PreviewFont.Charset = DEFAULT_CHARSET
PreviewFont.Color = clWindowText
PreviewFont.Height = -11
PreviewFont.Name = 'Tahoma'
PreviewFont.Style = []
Left = 41
Top = 66
end
object ImageEnIO1: TImageEnIO
PreviewFont.Charset = DEFAULT_CHARSET
PreviewFont.Color = clWindowText
PreviewFont.Height = -11
PreviewFont.Name = 'Tahoma'
PreviewFont.Style = []
Left = 76
Top = 66
end
object OpenPictureDialog1: TOpenPictureDialog
Left = 118
Top = 66
end
object SavePictureDialog1: TSavePictureDialog
Left = 154
Top = 69
end
end
Here are the png images for testing:
Road Background
Car
Result
Two Cars
STEPS
1. Open the road background.png
2. Add a layer
3. Open the car.png
4. Position the car with the mouse
5. Rotate the car as many times as you want at 45 degrees. (Angle does not matter}
6. Merge the layers
7. Save to a file
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development