Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotating an image, omg I cant !!!
01-03-2013, 01:11 AM
Post: #1
Rotating an image, omg I cant !!!
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.
Find all posts by this user
Quote this message in a reply
01-03-2013, 01:26 AM
Post: #2
RE: Rotating an image, omg I cant !!!
Hi! After setting the angle try the VLRotate ProcessBitmap method.

Regards,
Dave
Quote this message in a reply
01-03-2013, 01:47 AM
Post: #3
RE: Rotating an image, omg I cant !!!
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.
Find all posts by this user
Quote this message in a reply
01-03-2013, 05:10 AM
Post: #4
RE: Rotating an image, omg I cant !!!
Check the VLRotate.RotateOffset.Mode, make sure it's set to cmCenter.

Regards,
Dave
Quote this message in a reply
01-03-2013, 06:46 AM (This post was last modified: 01-03-2013 06:50 AM by oliveiracarlos.)
Post: #5
RE: Rotating an image, omg I cant !!!
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-WCIyM...lI4dDlBdWc
(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.
Find all posts by this user
Quote this message in a reply
01-03-2013, 10:54 AM
Post: #6
RE: Rotating an image, omg I cant !!!
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
Quote this message in a reply
01-04-2013, 05:28 AM
Post: #7
RE: Rotating an image, omg I cant !!!
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.
Find all posts by this user
Quote this message in a reply
01-04-2013, 09:16 AM
Post: #8
RE: Rotating an image, omg I cant !!!
Try Image2.Center=true;

Regards,
Dave
Quote this message in a reply
01-05-2013, 04:31 AM
Post: #9
RE: Rotating an image, omg I cant !!!
Simple and perfect solutions, thanks a lot mr Dave.
Find all posts by this user
Quote this message in a reply
01-05-2013, 06:07 AM
Post: #10
RE: Rotating an image, omg I cant !!!
You're welcome Smile
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)