Author Topic: CardLoadImage Problem  (Read 3656 times)


  • Newbie
  • *
  • Posts: 24
CardLoadImage Problem
« on: October 21, 2016, 04:55:31 PM »
So, I've been messing around with adding an image as the background of a card instead of using a solid colour.  It seems this should be doable with CardLoadImage, however, when I use that function the program cannot compile due to a "File name not found!" error.  Here is the code I am using in the Startup script:


BG.png is loaded into the image library.  It is also present in the directory under Resources>Pictures.  Just wondering what I'm doing wrong.

Conversely, I also toyed with just using a canvas but, when I make a canvas, it covers up all the fields and buttons I have and I cannot find a way to adjust the layers to push the canvas into the background.

Any help would be much appreciated!



  • Administrator
  • Newbie
  • *****
  • Posts: 420
  • Here to help you
Re: CardLoadImage Problem
« Reply #1 on: October 21, 2016, 09:05:30 PM »
Its not working because the CardLoadImage command only loads an image from a file and not from the Image Resource library.

Code: [Select]
@ Card 5, fname loads image from project folder, 1 = scale image

Note there is also the command CardLoadImageAbs that loads the image from an absolute file path.

The CardLoadImage commands could be bit slow if used when a card loads - I usually do the loading in the MainCode - Startup section - preload the image into an Image Bank slot then use the CardBankImage command to display the image from the image bank onto the card.

The CardLoadImage command was really useful many years ago when computers didn't have much RAM but today holding multiple images in the image bank are both feasible and also display the image very quickly.

The project Books HC shows how to preload the images into a bank and then access them using code similar to that below:-

Code: [Select]
@ Preload images.
Local okay,numcards,n

@ just reserve space for 1 image

@ check if enough memory etc
Put ImageBankSetSizeFN(1,640,480) into okay
If okay=1 Then
    @ --- Home Card ---
    @ --- Template Card 2 ---
    @ --- For Player with more data cards ---
    Put TotalCardsFN into numcards
    If numcards>2 Then
        For n=1 To numcards

ADDITION 22.10.16

Regarding your own image situation - with BG.png in Resources\Pictures:-

Code: [Select]
Local path

Put MyDirectoryFN into path
Append '\Resources\Pictures\BG.png' onto path

« Last Edit: October 22, 2016, 05:29:38 AM by Malkom »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.


  • Newbie
  • *
  • Posts: 24
Re: CardLoadImage Problem
« Reply #2 on: November 01, 2016, 08:16:50 PM »
That seems to be working pretty well.  Thanks so much for your help!