Board index » cppbuilder » Loading an Image at run-time

Loading an Image at run-time

I'm new at C++ Builder and am wondering if anyone can help me with
loading a image at runtime.

Any help is appreciated

 

Re:Loading an Image at run-time


Loading it to where from where?  If it is from a file try:

  Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap();
  Graphics::TBitmap *Bitmap2 = new Graphics::TBitmap();
  try
  {
    Bitmap1->LoadFromFile("C:\\Program Files\\Common Files\\Borland
Shared\\Images\\Splash\\256color\\factory.bmp ");
    Bitmap2->Assign(Bitmap1);     // Copy Bitmap1 into Bitmap2
    Bitmap2->Dormant();           // Free up GDI resources
    Bitmap2->FreeImage();         // Free up Memory.
    Canvas->Draw(20,20,Bitmap2);  // Note that previous calls don't lose
the image

    Bitmap2->Monochrome = true;
    Canvas->Draw(80,80,Bitmap2);
    Bitmap2->ReleaseHandle();       // This will actually lose the
bitmap;
  }
  catch (...)
  {
    MessageBeep(0);
  }
  delete Bitmap1;
  delete Bitmap2;

Quote
kdnb wrote:

> I'm new at C++ Builder and am wondering if anyone can help me with
> loading a image at runtime.

> Any help is appreciated

Other Threads