how to convert ScaleLeft from VB6 to delphi

when I use TImage to draw a graphics everytime the start point is from top-left corner (0,0), but in my case i want to the start point from bottom-right. I looked through VB6 they have such a scaleleft, scaletop to refine the size of the picture box. but in delphi you only can find scalewidth and scaleheight which cant really work properly. my question is how can i convert scaleleft and scaletop to delphi.
in VB6 the code like:
XPminimum=1000000#
XPmaximum=-1000000#
YPminimum=1000000#
YPmaximum=-1000000#
 
picture1.scaleleft=XPminimum-100
picture1.scalewidth=XPmaximum-XPminimum+100
picture1.scaletop=YPmaximum+100
picture.scaleheight=-1*(YPmaximum-YPminimum+100)
 
I also realized that in delphi you cant set negative in scale range, but if you cant then you cant let the graphics start drawing from the middle since the (0,0) is in the middle. any help will be appreciated

Open in new window

yanloveqooAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tobjectpascalCommented:
type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

Const
 XPminimum: Integer = 1000000;
 XPmaximum: Integer =-1000000;
 YPminimum: Integer =1000000;
 YPmaximum: Integer =-1000000;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
// Image1.Stretch:=True; //Fit To Scale
Image1.left:=XPminimum-100;
Image1.width:=XPmaximum-XPminimum+100;
Image1.top:=YPmaximum+100;
Image1.height:=-1*(YPmaximum-YPminimum+100);
end;

I think you might be talking about Stretch, it fits the image (the [additional] tab] TImage to the value you specify, without it, you'll just see the area you set.
0
ziolkoCommented:
put Panel on your form and set it's size it to size you want your image to be then (I assume that picture itself is bigger than space on your form to display it)
place Image on Panel (not on form, in this case image should be bigger than panel) and set Image's properties:
AutoSize := True;
Left := 0;
Top := 0;
Align := alNone;

then use:

procedure TForm1.Button3Click(Sender: TObject);
begin
  if Image1.Left = 0 then begin
    Image1.Left := Panel1.Width - Image1.Width;
    Image1.Top  := Panel1.Height - Image1.Height;
  end else begin
    Image1.Left := 0;
    Image1.Top  := 0;
  end;
end;


everytime you hit button it wil make image to appear like it's alligned to top-left corner or bottom-right one

ziolko.
0
yanloveqooAuthor Commented:
To tobjectpascal:

I've tried your solution. it works fine if you just creat a new form it will create a vertical scrollbar that allow you to scroll down the stretched image, but when you start to draw a line say start from (600,600) to (1000,1000) it would produced an error said parameter incorrect. i was thinking it might be the negative points but when i swaped it to positive still generated the same result.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

developmentguruPresidentCommented:
 I think the TImage control that you are trying to use as the VB control is simply not the same.  You could place a TPanel control on the form to act as your container at 400 by 400 and place the TImage inside it.  The you just need to place the left and top of the TImage to the appropriate values to move it to the lower right of the panel.  If you have a panel that is 400 by 400 and a TImage that is 200 by 200 then the code to place it in the lower right corner would look something like this...

Image1.Left := Panel1.Width - Image1.Width;
Image1.Top := Panel1.Height - Image1.Height;

Of course this works best if the image.autosize is true.  Let me know if this works for you.
0
ziolkoCommented:
@developmentguru

isn't that same what I posted?

ziolko.
0
developmentguruPresidentCommented:
I was typing and did not see ziolko's comment...
0
yanloveqooAuthor Commented:
I've tried the to put the image inside panel, it seems not really what i want. when you load a pic from image you can see the pic moved, but when i try to draw a diagram it doesnt show anything
0
yanloveqooAuthor Commented:
there are two files which displayed different. like i said if you put picture.scaleleft, scalewidth,scaletop,scaleheight in the program it will show as 2.bmp. the different between these two pic is the 1st one shows up-side-down result which means the 0,0 is at top-left, the 2nd one shows the other way the 0,0 point change to the down side. i try to find a way to convert these pieces of codes in delphi, but i t wasnt very succeed
1.bmp
2.bmp
0
developmentguruPresidentCommented:
So... you want to scale the image including changing the coordinate system so that when you draw a line it draws it in the opposit direction?  I need more clarification.

1) Do you plan to load an image or use a blank image to start?
2) If you plan to load an image, do you want it to be inverted vertically?  horizontally?
3) When you draw do you want the drawing commands to be inverted vertically?  horizontally?

Let me know.
0
yanloveqooAuthor Commented:
The image was drawed by calculated X,Y point and was using Move to and Line to from Canvas.
I just want to the image vertically twist to the other side
0
developmentguruPresidentCommented:
Place 2 TImage controls and a button on the form and use the attached code as the button click routine.  This will take an image and flip it around it's vertical center.  The rest is just moving it.  You should be able to apply it to what you are trying to do.
procedure TForm1.Button1Click(Sender: TObject);
var
  Bitmap : TBitmap;
  S, D : TRect;
 
begin
  Bitmap := TBitmap.Create;
  Bitmap.Width := Image1.Width;
  Bitmap.Height := Image1.Height;
  Image1.Canvas.CopyMode := cmSrcInvert;
  S := Rect(0, 0, Bitmap.Width, Bitmap.Height);
  D := S;
  Bitmap.Canvas.CopyRect(D, Image1.Canvas, S);
 
  D.Left := S.Right;
  D.Right := S.Left;
  Image2.Canvas.CopyRect(D, Bitmap.Canvas, S);
end;

Open in new window

0
developmentguruPresidentCommented:
P.S. You will need to load Image1 with an image to see anything...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.