Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Scale Image In Grid
Wed, May 31 2017 4:28 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

HI,

I am having trouble getting an image in a grid to scale to show the
whole image.

I have an image as a Base64 encoded string (downloaded from the server)
and I can display it on the screen using TImage background and stContain
and it displays the whole image.

But if I create a column in  a Grid and set the column control type to
be ctImage and the ImageLayout siz eto be csContain it only shows a
portion of the image.

(See attached screenshot)

Any ideas?

--
Chris Holland
[Team Elevate]



Attachments: Scale Image.jpg
Wed, May 31 2017 5:02 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

I forgot to mention I have this code on the Cell update as well to get
the image to appear:


procedure TSelectAreaForm.AuditGridImageColCellUpdate(Sender: TObject;
ACell: TGridCell);
begin
   ACell.Background.Image.Name := 'data:image/jpeg;base64,' + ACell.Data;
end;

Chris Holland
[Team Elevate]

On 31/05/2017 09:28, Chris Holland wrote:
> HI,
>
> I am having trouble getting an image in a grid to scale to show the
> whole image.
>
> I have an image as a Base64 encoded string (downloaded from the server)
> and I can display it on the screen using TImage background and stContain
> and it displays the whole image.
>
> But if I create a column in  a Grid and set the column control type to
> be ctImage and the ImageLayout siz eto be csContain it only shows a
> portion of the image.
>
> (See attached screenshot)
>
> Any ideas?
>

--
Chris Holland
[Team Elevate]
Wed, May 31 2017 12:58 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

<< But if I create a column in  a Grid and set the column control type to be ctImage and the ImageLayout siz eto be csContain it only shows a portion of the image. >>

I'm looking into this....

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jul 3 2017 2:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

Okay, sorry for the long delay on getting back to you on this.

The issue is that you're setting the background image, but using the layout options for non-background images.  For non-background images (ControlType=ctImage), the URL for the image is supplied in the data for the actual cell, not via the background image name.  You can do this with a calculated dataset column, if you need to prefix the incoming data so that it is recognized as a data url image.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 5 2017 8:03 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

Hi Tim,

My problem seems to be that I cannot set the data for an image col from
a data table string.

For my normal images I just set the background image with something like
this:

AreaImage.URL := 'data:image/jpeg;base64,' + Area.ImageData;

Where the 'Area.ImageData' is a Base64 encoded string created from an image.

=====================

If I setup a grid column with ControlType := ctImage
and the DataColumn pointing to a string field in a table containing the
same data, no image appears.


Chris Holland
[Team Elevate]

On 03/07/2017 19:09, Tim Young [Elevate Software] wrote:
> Chris,
>
> Okay, sorry for the long delay on getting back to you on this.
>
> The issue is that you're setting the background image, but using the layout options for non-background images.  For non-background images (ControlType=ctImage), the URL for the image is supplied in the data for the actual cell, not via the background image name.  You can do this with a calculated dataset column, if you need to prefix the incoming data so that it is recognized as a data url image.
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
Wed, Jul 5 2017 11:54 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

<< If I setup a grid column with ControlType := ctImage and the DataColumn pointing to a string field in a table containing the same data, no image appears. >>

Does the data contain the proper data-url prefix ?  If not, then that is why I recommended a calculated column that adds it to the data.  You could also use an OnGetText event handler for the data column in order to add the proper prefix.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 6 2017 7:49 AMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

Hi Tim,

Yes the data starts with this:

data:image/jpeg;base64,     ......etc

Chris Holland
[Team Elevate]

On 05/07/2017 16:54, Tim Young [Elevate Software] wrote:
> Chris,
>
> << If I setup a grid column with ControlType := ctImage and the DataColumn pointing to a string field in a table containing the same data, no image appears. >>
>
> Does the data contain the proper data-url prefix ?  If not, then that is why I recommended a calculated column that adds it to the data.  You could also use an OnGetText event handler for the data column in order to add the proper prefix.
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
Thu, Jul 6 2017 10:58 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

<< Yes the data starts with this:

data:image/jpeg;base64,     ......etc >>

Okay, it's an issue with the semicolon in the data-URL.  I'm going to have to put in a check for this.

I've got to do a new build 4, anyway, though, due to a bug in the local web server debug logging, so that will be out today and it will include this fix.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 6 2017 2:55 PMPermanent Link

Chris Holland

SEC Solutions Ltd.

Avatar

Team Elevate Team Elevate

That has fixed it thanks Tim.

Chris Holland
[Team Elevate]

On 06/07/2017 15:58, Tim Young [Elevate Software] wrote:
> Chris,
>
> << Yes the data starts with this:
>
> data:image/jpeg;base64,     ......etc >>
>
> Okay, it's an issue with the semicolon in the data-URL.  I'm going to have to put in a check for this.
>
> I've got to do a new build 4, anyway, though, due to a bug in the local web server debug logging, so that will be out today and it will include this fix.
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
>
Thu, Jul 6 2017 4:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Chris,

<< That has fixed it thanks Tim. >>

Cool, thanks for the update. Smile

Tim Young
Elevate Software
www.elevatesoft.com
Image