Forums
Rotating an image, omg I cant !!! - Printable Version

+- Forums (http://mitov.com/forum)
+-- Forum: VCL Components (/forum-6.html)
+--- Forum: VideoLab (/forum-19.html)
+--- Thread: Rotating an image, omg I cant !!! (/thread-1306.html)



Rotating an image, omg I cant !!! - oliveiracarlos - 01-03-2013 01:11 AM

Please people help me to rotate a simple image. I´m using Delphi.

My code is working. In my form i have one TVLDSImageDisplay and one TLVRotate. I dont know how to rotate the image after display. Inside the "TLVRotate.InpuPin" property, there is nothing to select.

This is my code:
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
img : TBitmap;
jpg : TPicture;
begin

jpg := TPicture.Create;
jpg.LoadFromFile('D:\jucerun\delphi\MidiDelphi\VolumeKnob.jpg');

img := TBitmap.Create;
img.Width := 121;
img.Height := 121;
img.Canvas.Draw(0,0,jpg.Graphic);

VLRotate1.Angle := 90;
VLDSImageDisplay1.DisplayBitmap(img);
end;


Pleaseeeeee !!!
thanks.


RE: Rotating an image, omg I cant !!! - Dave - 01-03-2013 01:26 AM

Hi! After setting the angle try the VLRotate ProcessBitmap method.

Regards,
Dave


RE: Rotating an image, omg I cant !!! - oliveiracarlos - 01-03-2013 01:47 AM

Dave, it works...

But after set the angle value the image do not rotate over the center ! Take a look please.
http://s9.postimage.org/lwf1m5s33/knob_Img1.jpg
http://s9.postimage.org/4kep0pylr/knob_Img2.jpg
http://s9.postimage.org/uh8ddc29b/knob_Img3.jpg

thanks.


RE: Rotating an image, omg I cant !!! - Dave - 01-03-2013 05:10 AM

Check the VLRotate.RotateOffset.Mode, make sure it's set to cmCenter.

Regards,
Dave


RE: Rotating an image, omg I cant !!! - oliveiracarlos - 01-03-2013 06:46 AM

Thanks for reply Dave.

But yes, its cmCenter. No matter what I do, I cant center the button.

If you have some time to help, appreciate that: https://docs.google.com/open?id=0B-WCIyMlx7bxOHZKTlI4dDlBdWc
(Its a Delphi XE project)

all the code is as following...
Code:
unit uKnobButton;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, LPControl, SLControlCollection, VLCommonDisplay, VLImageDisplay,
  SLCommonGen, VLCommonGen, VLImageGen, LPComponent, SLCommonFilter,
  VLCommonFilter, VLRotate, VLAVIPlayer, VLDSImageDisplay, MLDSPlayer,
  VLDSVideoPlayer, VLGrayScale, StdCtrls, Jpeg, pngimage, GIFImg, VLWarp,
  ExtCtrls, VLBasicGenericFilter, VLGenericFilter, ComCtrls;

type
  TForm1 = class(TForm)
    VLDSImageDisplay1: TVLDSImageDisplay;
    Image2: TImage;
    TrackBar1: TTrackBar;
    VLRotate1: TVLRotate;
    procedure TrackBar1Change(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

  var
img : TBitmap;
jpg : TPicture;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
jpg := TPicture.Create;
jpg.LoadFromFile('D:\jucerun\delphi\MidiDelphi\VolumeKnob.jpg');

img := TBitmap.Create;
img.Width := 121;
img.Height := 121;
img.Canvas.Draw(0,0,jpg.Graphic);

VLDSImageDisplay1.DisplayBitmap(img);
end;

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
VLRotate1.Angle := TrackBar1.Position;
VLRotate1.ProcessBitmap(img,image2.Picture.Bitmap);
end;

end.

Code:
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 225
  ClientWidth = 341
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnActivate = FormActivate
  PixelsPerInch = 96
  TextHeight = 13
  object Image2: TImage
    Left = 200
    Top = 16
    Width = 121
    Height = 121
  end
  object VLDSImageDisplay1: TVLDSImageDisplay
    Left = 16
    Top = 16
    Width = 121
    Height = 121
    AspectRatio.Width = 4
    AspectRatio.Height = 3
    Graph.AdditionalFilters = <>
  end
  object TrackBar1: TTrackBar
    Left = 16
    Top = 168
    Width = 305
    Height = 45
    Max = 360
    TabOrder = 1
    OnChange = TrackBar1Change
  end
  object VLRotate1: TVLRotate
    WorkArea.Width = 1
    WorkArea.Height = 1
    BackgroundColor = clWhite
    SmoothEdge = False
    Left = 152
    Top = 67
    _Floats = (
      (
        Angle
        0.000000000000000000))
  end
end

thanks in advanced.


RE: Rotating an image, omg I cant !!! - Dave - 01-03-2013 10:54 AM

Try this:

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
VLRotate1.Angle := TrackBar1.Position;
VLRotate1.ProcessBitmap(img,img);
VLDSImageDisplay1.DisplayBitmap(img);

You'd probably want to re-assign the original image to img once you did this. If it still fails i can have a look at the project tommorow. Is the original image 121x121 btw?

Regards,
Dave


RE: Rotating an image, omg I cant !!! - oliveiracarlos - 01-04-2013 05:28 AM

Sorry Dave, but it doesnt work...

Adding this last line the image flicks a lot and still not rotating in center.

Yes the image has 121x121.

:///

thanks for your help.


RE: Rotating an image, omg I cant !!! - Dave - 01-04-2013 09:16 AM

Try Image2.Center=true;

Regards,
Dave


RE: Rotating an image, omg I cant !!! - oliveiracarlos - 01-05-2013 04:31 AM

Simple and perfect solutions, thanks a lot mr Dave.


RE: Rotating an image, omg I cant !!! - Dave - 01-05-2013 06:07 AM

You're welcome Smile