Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help loading images !

zivlakszivlaks Member Posts: 3
Hello guys , I was wondering if anyone on this forum could help me with this code :

[code]
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i,n=12;
for(i=0;iTag)+".bmp";

Image[i]->Picture->LoadFromFile(sl);


};[/code]

I need to load 12 images for my puzzle game but it keeps telling me that [b]value 'Image' is not defined[/b] . Can you tell me how to define it ?( funny thing is if I just put Image1 or Image2 it works - but I need to load all 12 images ) . Thanks for replies !

Comments

  • tojoheretojohere Member Posts: 4
    : Hello guys , I was wondering if anyone on this forum could help me
    : with this code :
    :
    : [code]:
    : void __fastcall TForm1::Button1Click(TObject *Sender)
    : {
    : int i,n=12;
    : for(i=0;iTag)+".bmp";
    :
    : Image[i]->Picture->LoadFromFile(sl);
    :
    :
    : };[/code]:
    :
    : I need to load 12 images for my puzzle game but it keeps telling me
    : that [b]value 'Image' is not defined[/b] . Can you tell me how to
    : define it ?( funny thing is if I just put Image1 or Image2 it works
    : - but I need to load all 12 images ) . Thanks for replies !
    :


    Buddy, your question seems unclear.
    Are you getting a compile error ?
    Whats the type of Image variable u are referring to?

  • bilderbikkelbilderbikkel Member Posts: 754
    The error is in this line:

    [code]
    Image[i]->Picture->LoadFromFile(sl);
    [/code]

    If you have TImages called 'Image1', 'Image2', etc., this does not work.

    The solution that does work is to create a std::vector of TImage and work with this std::vector.

    [code]
    std::vector images;
    images.push_back(Image1);
    images.push_back(Image2);
    images.push_back(Image3);
    images.push_back(Image4);
    //etc.

    for (/* all images */)
    {
    const String s = /* something */;
    images[i]->Picture->LoadFromFile(sl);
    }
    [/code]

    Good luck, Bilderbikkel
Sign In or Register to comment.