Jump to content


Photo

Direct load image from the web to TNxImageColumn or TNxGraphicColumn

TNxImageColumn direct_load image

  • Please log in to reply
5 replies to this topic

#1 IUnknown

IUnknown
  • Members
  • 13 posts
  • Gender:Male
  • Location:Niedersachsen, Deutschland
  • Interests:COM/Multithreading/API/eCommerce

Posted 19 August 2014 - 01:41 AM

Team,

Is there any way to directly load an image from the web URL to TNxImageColumn or to TNxGraphicColumn ?

For example, I want to load to TNxImageColumn an image from http://www.mysite.com/myimage.jpg
How do I do that? Is there any option to avoid dealing with image lists?

Thanks
Vsevolod
There are 10 types of people. Those who understand binary and those who don't.

#2 IUnknown

IUnknown
  • Members
  • 13 posts
  • Gender:Male
  • Location:Niedersachsen, Deutschland
  • Interests:COM/Multithreading/API/eCommerce

Posted 19 August 2014 - 01:42 AM

[Sorry, the URL in the above example was linked automatically]
There are 10 types of people. Those who understand binary and those who don't.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 19 August 2014 - 11:46 AM

Hi,

ImageColumn is more for icons from TImageList. Maybe you can use Graphic Column instead. Please check this tutorial:

http://dn.bergsoft.n...mn-tutorial.htm

I hope that it will helps.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 IUnknown

IUnknown
  • Members
  • 13 posts
  • Gender:Male
  • Location:Niedersachsen, Deutschland
  • Interests:COM/Multithreading/API/eCommerce

Posted 23 August 2014 - 12:28 PM

Hi Boki,
Thanks for the tutorial.

It seems that
ObjectReference
property stores only an active object. When I free the reference to this object the NextGraphic column also disappears.
In my case I need a persistent bitmap to be displayed in a column. Here is my quick research:

I wrapped the logic of downloading a bitmap from URL into a simple function
DownloadImage(const Url: string): TBitmap;
Then I coded as per your suggestion:

var
  G: TGraphic;
  Grid.AddRow;
  Grid.RowHeight[0] := 50;
  try
    G := DownloadImage('http://web/my.jpg');
    Grid.Cell[0, 0].ObjectReference := G;
  finally
    G.Free;
  end;

The image seems to load -BUT- when I
finally G.Free
the object, it is destroyed and the image is disappeared.
If I do not free the object my app leaks memory when I close the form.

I guess we need some techniques here to make the image persistent (something like using
Assign(Source: TPersistent)
) and then let VCL do all garbage collection.
Any ideas?
There are 10 types of people. Those who understand binary and those who don't.

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 23 August 2014 - 04:18 PM

Hi,

Maybe before form is closed/destroyed , you simply run trough all objects and release them?

I may add auto-free but what will be if object is interface?
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 IUnknown

IUnknown
  • Members
  • 13 posts
  • Gender:Male
  • Location:Niedersachsen, Deutschland
  • Interests:COM/Multithreading/API/eCommerce

Posted 24 August 2014 - 01:05 AM

Hi Boki,
Thanks for your input. It is always appreciated and carefully reviewed.

This afternoon I found a workaround to my particular case. Tough it has nothing to do with TNxGraphicColumn - but with TNxImageColumn and TImageList instead.
I create ImageList at run-time, then download JPEGs from the web as TBitmap, then
ImageList.Add(bmp, nil)
and finally assign ImageList to grid and set image index.

This approach works better in my case and looks like a good coding-style.

Thanks
Vsevolod
There are 10 types of people. Those who understand binary and those who don't.





Also tagged with one or more of these keywords: TNxImageColumn, direct_load, image

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users