Announcement

Collapse
No announcement yet.

file_LoadImageControl dynamically

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • file_LoadImageControl dynamically

    Is it possible to use a generated string as filename??
    This is to load a circleX from sdcard and does not work.

    What am I doing wrong?

    func loadImageDyn(var INTERVAL)

    gfx_TransparentColour(YELLOW); gfx_Transparency(ON); var circle; var buffer[10]; to(buffer);print("circle"); to(APPEND);print(INTERVAL); to(APPEND);print(".Dat"); //putstr(buffer);
    var buffer2[10]; to(buffer2);print("circle"); to(APPEND);print(INTERVAL); to(APPEND);print(".Dat"); circle := file_LoadImageControl(buffer ,buffer2 ,0); mem_Free(circle);

    endfunc

    Thanks
    Raymond

  • #2


    I found it almost:

    gfx_TransparentColour(YELLOW); gfx_Transparency(ON); var circle; var p; var buffer[10]; //to(buffer);print("circle"); //to(APPEND);print(INTERVAL); //to(APPEND);print(".Dat"); p := str_Ptr(buffer); str_Cat(p,"circle");
    str_Cat(p, INTERVAL);

    Comment


    • #3


      This works!! But What if interval > 9????? somebody an idea??

      var image, p, n; var buffer[10]; /*z[n++] := "circle"; z[n++] := INTERVAL; z[n++] := ".Dat";*/ p := str_Ptr(buffer); str_Cat(p,"circle"); //str_Cat(p, "0"); str_PutByte(p+6,INTERVAL+48); str_Cat(p,".Dat"); putstr(buffer); /* putch(buffer[0]); // write single char to current output device(buffer); putch(buffer[1]); putch(buffer[2]); putch(buffer[3]); putch(buffer[4]); putch(buffer[5]); putch(buffer[6]); putch(buffer[7]); */ //str_Printf(&p, "%*s%d%*s"); // print("print p:");putstr(p); // print(z); gfx_TransparentColour(YELLOW); gfx_Transparency(ON); image := file_LoadImageControl(p ,"circle0.Gci",0); img_Show(image, 0); mem_Free(image); gfx_Transparency(OFF);

      Comment


      • #4
        Why not try

        to(buffer) ;
        print("circle",INTERVAL,".dat\0") ;
        putstr(buffer) ;
        ....
        image := file_LoadImageControl(str_ptr(buffer),"circle0.Gci",0);
        Mark

        Comment


        • #5


          Thanks Mark

          this works even better!!

          Now I can make a seperate file for every image I need and load that and mem_Free it.
          This gives me much more free memory. In the project I am making it saves me already 3Kb.

          Is using the raw method(on sdcard) much faster than the FAT16 method I am using now?


          greetings
          Raymond

          Comment

          Working...
          X