From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 26: | Line 26: | ||
|- | |- | ||
|Margins ||testImg.Margins.Left:= 50; // Right, Top, Bottom ||With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.<br>[[File:TclImageMargins.png|frameless|200px]] | |Margins ||testImg.Margins.Left:= 50; // Right, Top, Bottom ||With the Margins parameter, you can give margins at any scale from the right, left, bottom, top.<br>[[File:TclImageMargins.png|frameless|200px]] | ||
|- | |||
| LoadFromFile ||testImg.Bitmap.LoadFromFile('C:\Users\Administrator\Desktop\logo.png') || The LoadFromFile method in Clomosy is used to load an image file and transfer it to a bitmap object. In the example, the expression testImg.Bitmap.LoadFromFile loads an image from a file path into the Bitmap property of a component named testImg. | |||
|} | |} | ||
Revision as of 08:41, 11 July 2024
If you want to add an image within the application, you can use the "TclImage" component. This component is defined as follows.
AddNewImage (TComponent, xName): TClImage
TComponent : The variable name of the defined component is written. Here you should write the component variable name of whatever your component will be in.
xName : The name of the defined image should be written.
| Feature | Use of | Definition |
|---|---|---|
| TclImage | testImg : TclImage; | A variable belonging to the TclImage class is created. |
| AddNewImage | testImg:= MyForm.AddNewImage(MyForm,'testImg'); | A new Image is added to the form. |
| setImage | MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png'); | It is used if you want to add an image to the Image object. |
| Clear | testImg.MultiResBitmap.Clear; | The Clear method clears images at all resolution levels within a MultiResBitmap property. So, when this method is called, all the images in the MultiResBitmap are deleted and rendered to an empty state. |
| Width | testImg.Width := 150; | Allows adjusting the width of the image. |
| Height | testImg.Height := 50; | Allows adjusting the height of the image. |
| Align | testImg.Align := alTop; | With the Align parameter, you can specify where you want our component to be aligned in the form. This parameter has multiple positioning properties. See the page to learn about these features. |
| Margins | testImg.Margins.Left:= 50; // Right, Top, Bottom | With the Margins parameter, you can give margins at any scale from the right, left, bottom, top. |
| LoadFromFile | testImg.Bitmap.LoadFromFile('C:\Users\Administrator\Desktop\logo.png') | The LoadFromFile method in Clomosy is used to load an image file and transfer it to a bitmap object. In the example, the expression testImg.Bitmap.LoadFromFile loads an image from a file path into the Bitmap property of a component named testImg. |
Example:
- Base Syntax
var MyForm:TclForm; testImg : TclImage;
begin MyForm := TclForm.Create(Self); testImg:= MyForm.AddNewImage(MyForm,'testImg'); testImg.Align := alCenter; testImg.Height := 250; testImg.Width := 300;
MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png'); MyForm.AddNewEvent(testImg,tbeOnClick,'ShowMessage(''Picture clicked.'');'); MyForm.Run;
end;
- TRObject Syntax
var
MyForm:TclForm;
testImg : TclImage;
{
MyForm = TclForm.Create(Self);
testImg= MyForm.AddNewImage(MyForm,'testImg');
testImg.Align = alCenter;
testImg.Height = 250;
testImg.Width = 300;
MyForm.setImage(testImg,'https://clomosy.com/demos/bg.png');
MyForm.AddNewEvent(testImg,tbeOnClick,'ShowMessage(''Picture clicked.'');');
MyForm.Run;
}