5

Looked in the delphi help and could not find out when one should use each component over the other...

I am wondering what the differences are between these very similar controls: TImage, TImageViewer, and TImageControl.

I am interested in displaying multiple images on a form, to scroll through in a scrollbox; but all three of those components could be used, and I have no idea which one to choose!

anu
  • 1,017
  • 1
  • 19
  • 36
Programmz
  • 149
  • 5
  • Depending on your needs, quite possibly you'd not use any of these controls. If there are a lot of images, then you really don't want to create one control for each image. – David Heffernan Nov 22 '17 at 12:00
  • was thinking of just generating multiple TImage at run time into a scroll box, but there may be a component that already does something like this automatically. – Programmz Nov 22 '17 at 12:01
  • Expect that approach to have poor performance as you scale to large numbers of images – David Heffernan Nov 22 '17 at 12:02
  • 2
    I will do some tests on about 100-200 images and report back, indeed that was a concern of mine. Still interested in finding out differences between those image components regardless – Programmz Nov 22 '17 at 12:26
  • What research have you done. A question asking "what is the difference between these three things" doesn't really fit here on SO. Falls into the category of "too broad". – David Heffernan Nov 22 '17 at 12:29
  • The delphi help files are the research I did since they should let the user know what each component is for, and the help files are too terse... I googled it and could not find much – Programmz Nov 22 '17 at 13:13
  • Compare in help in turn, inheritance tree, methods (inherited off, protected on) and properties (with inherited off). That will give you plenty of clues of what each offers. And of course, read the little that is said in the description for each. F.ex. `TImageViewer` descends from `TCustomScrollBox` which is very different from the others. – Tom Brunberg Nov 22 '17 at 14:01
  • Tom Brunberg, the delphi help description section is very terse and does not go into detail what the components are for. p.s. loading 150 TImages into a scrollbox only takes 6 seconds and works for my needs... 6 seconds is fast enough... esp. for that amount of data! But, Maybe TImageViewer is what I am after, I will look into it - it's probably just to scroll a single image at a time, though. – Programmz Nov 22 '17 at 14:58
  • Just two days ago I was trying to accomplish the exact precise same thing, using Firemonkey, and somehow managed to bluescreen my PC. – Jerry Dodge Nov 22 '17 at 20:04
  • bluescreen because you dynamically created TImage? I have some code that makes it work if you want, I can send/upload – Programmz Nov 22 '17 at 23:03
  • Interesting, `TImageViewer` and `TImageControl` are not in `VCL`. Just `FireMonkey`. – Aqil Nov 22 '17 at 23:04

2 Answers2

2

Hi, I've just found this answer (from Alexander Brazda), because I wanted to know as well:

"..If you need to display a simple image (without borders, scroll bars, etc) use TImage this like a fmx primitive like any other shape (TRectangle, TCircle, TEllipse, TPipe, ...)

For an image with a control style (border, background, etc) use TImageControl

and for Zoom, Scroll, Dialogs, etc use TImageViewer.

TImage its simplex (just draw a image over a control where its placed), TSyledControls use a collection of objects to draw and copy values from control properties to style objects.

Of course you can use a TRectangle and Fill it with a TBitmap Brush. Image with WrapMode=Original and BitmapMargins empty would call Canvas.DrawBitmap() with any transformation (except screen scale if defined)..."

You can see the post : Google+ Delphi Developers forum

Tamas
  • 106
  • 1
  • 6
0

Apart from the answer by Tamas, note this from https://docwiki.embarcadero.com/Libraries/Sydney/en/FMX.ExtCtrls.TImageViewer

Platform Support

Rotating an image viewer using its RotationAngle and RotationCenter properties is only supported on desktop platforms. Rotating an image viewer on mobile platforms might produce unexpected results.

George Birbilis
  • 2,782
  • 2
  • 33
  • 35