Jump to content

Load TW3Images from an array

Recommended Posts

I load all my images from the res/ folder into an array using the code from the ZenSky demo.

I have placed this code in the Application unit


    FImages:  Array of TW3Image; 
    FNames:   Array of String; 
    FCounter: Integer; 

(* number of images loaded into the cache *) 

  (* names of images to load *) 

  (* create equal number of image elements *) 
  for x:=0 to FNames.length-1 do 

(* initiate async loading on all *) 
  for x:=0 to FImages.Length-1 do 



I want to be able to assign the images to a TW3Image on another form. Example




I dont get any errors, all i get is an outline of a TW3Image control



Link to post
Share on other sites
  • Administrators

Sorry about the late response.


Yes. It is possible to convert the images to Base64 strings and include them in your project.

Take a look at the TSmiley demo. Here we have created a dedicated class to show various smiley images, and all the smiley images are included as string constants.



15 minutes later



I got a bit carried away here, so I altered the TSmiley class to a TCoinImage class :-)


Now you can just create a TCoinImage class and set the denomination you would like to show.

(Oh. Please give me some feedback on the terminology. Is "Denomination" OK to describe "Value"?)


  FCoinImage: TCoinImage; 
  FCoinImage := TCoinImage.Create(Self); 
  FCoinImage.SetBounds(40, 40, 100, 100); 
  FCoinImage.Denomination := Low(TCoinDenomination) + RandomInt(High(TCoinDenomination)+1); 



The images are represented like this (full code in demo below):

  CCoinImage: array [cdOneCent..cdOneDollar] of string = 
//** cdOneCent **// 
'g6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAiz' + 


The "show image" magic:

  InnerHTML := '<img valign="middle" align="middle" alt="" ' + 'src="' + GetCoinImage + '" />'; 



Full project: https://www.dropbox.com/s/fpediv9bom6u5e6/TCoinImage%20%28based%20on%20TSmiley%29.zip

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...