Jump to content
  • Advertisement
Sign in to follow this  

TImage (BCB 6)

This topic is 4696 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm using Borland C++ Builder 6 to create my map editor, and I was wondering if anyone knew how to create TImages (in a panel) at runtime. Even better how to create an array of them at runtime. I did this
//Global var
TImage *mapGrid;

//latern on the form load
mapGrid = new TImage[5](Panel1);
But it doesn't seem to work when I load in an image. Presumably b/c I haven't specified a size for the TImage as well as (x,y) coords for the actual TImage. So...how do I do this? Thanks!

Share this post

Link to post
Share on other sites
It's just the same as if you had of drug a TImage out and dropped it on Panel1 during development. The only differance is the position would have been where you clicked rather than the default position. My guess would be that the default position is the top left corner and the size is 100x100 pixels.

I don't believe a TImage actually does much of anything. It is just a window. You can draw into it using it's canvas, but has no actual storage for retaining the image. So it's no differant than just drawing into the panel. There is a differance in that a panel isn't designed for you to draw straight into and an image is. Rather a TImage has a TGraphic.

A TGraphic is an interface. You don't create TGraphics, but rather you inherit off of them. A TBitmap is a prime example. So if you want to display a bitmap in a TImage then you need to create a TBitmap and set the graphic property of the image to point to it. I believe alternatively you can set it's imagelist property to point to an image list and set the image index.

The size of the image is just the size of the window. An important property certainly since it controls how it will be displayed, but most likely you care more the size of the bitmap being displayed in it. If the bitmap is bigger than the image then you're going to need some programmatic means to see the rest of it such as scroll bars on the image. If it has a graphic then it will automatically blit the image to the screen for you and you can just draw in the bitmap using it's canvas.

I don't have the help available so I might be a bit fuzzy on a few details, but if my memory is correct that's how it works. I'm surprised it has a load function. I'm inclined to think you actually need a TGraphic assigned and all that load function will do is call the TGraphic's load function. If it used the .bmp on the end of the file name to create a TBitmap then who frees it and how do you use it to load a TGA, PNG, DSS or some other format for which support didn't come out of the box. So I would assume load isn't working because you don't have a TGraphic assigned to the image to do the actual loading.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!