Strange problem with TImageList

Strange problem with TImageList

Post by Ted Byer » Fri, 30 Jun 2000 04:00:00



Please consider the following code.

__fastcall TMyForm::TMyForm(TComponent* Owner)
  : TForm(Owner)
{
  Graphics::TBitmap *bmp1;
  bmp1 = new  Graphics::TBitmap;
  bmp1->Width = Screen->Width;
  bmp1->Height = Screen->Height;
  MyImage->Picture->Bitmap = bmp1;
  MyScrollBox->Align = alClient;
  maxNDX = 2;
  curBmpNDX = 0;
  MyImageList->Add(bmp1,NULL);
  MyImageList->GetBitmap(0,MyImage->Picture->Bitmap);

Quote:}

If I comment out the last line, all works as I expected, with an image the
size of my screen.  I have a draw function, executed from a command, so that
each time it is pressed, an ellipse is drawn in a random colour at a random
position with a random size.

The problem is that with the last line active, however, the image is a
square scarcely a third of a centimetre across.  Why would TImageList shrink
the bitmap so much?

The autosize property of the TImage component is set to true.  I require the
TImage to grow to the size of the bitmap.  And when I get to managing a list
of bitmaps (there will be 36, no less, no more), they will all be the same
size.

Would I be better off using an STL vector handled pointers to the bitmaps,
and putting code in the form's destructor to delete the bitmaps?

Are TBitmaps reference counted so I can safely use an assignment like

MyImage->Picture->Bitmap = bmps[i]

And subsequently draw to bmps[i].  And if so, is what I draw shown by the
Image it it's bitmap property is currently set to bmps[i], or do I have to
repeat the assignment?  I would suppose the smartest approach is to draw to
the bmps elements before they are shown.

Any suggestions?

Cheers,

Ted
R.E. Byers

 
 
 

Strange problem with TImageList

Post by Micha Nelisse » Sun, 02 Jul 2000 04:00:00



> Please consider the following code.

> __fastcall TMyForm::TMyForm(TComponent* Owner)
>   : TForm(Owner)
> {
> <snip>

> The problem is that with the last line active, however, the image is a
> square scarcely a third of a centimetre across.  Why would TImageList
shrink
> the bitmap so much?

What are TImageList's Width and Height properties, all bitmaps in the list
will be as big as those properties and shrunk to it when added.

Quote:> Would I be better off using an STL vector handled pointers to the bitmaps,
> and putting code in the form's destructor to delete the bitmaps?

No, if all bitmaps are equally as big, an ImageList is handier to use.

Quote:> Are TBitmaps reference counted so I can safely use an assignment like

> MyImage->Picture->Bitmap = bmps[i]

> And subsequently draw to bmps[i].

No! This won't work. It is the same as:

MyImage->Picture->Bitmap->Assign(bmps[i]);

which results into making a copy of the bitmap. Any change in bmps will only
change bmps, because MyImage is just a copy.

HTH,

Micha.

 
 
 

Strange problem with TImageList

Post by Ted Byer » Sun, 02 Jul 2000 04:00:00




> > Please consider the following code.

> > __fastcall TMyForm::TMyForm(TComponent* Owner)
> >   : TForm(Owner)
> > {
> > <snip>

> > The problem is that with the last line active, however, the image is a
> > square scarcely a third of a centimetre across.  Why would TImageList
> shrink
> > the bitmap so much?

> What are TImageList's Width and Height properties, all bitmaps in the list
> will be as big as those properties and shrunk to it when added.

> > Would I be better off using an STL vector handled pointers to the
bitmaps,
> > and putting code in the form's destructor to delete the bitmaps?

> No, if all bitmaps are equally as big, an ImageList is handier to use.

Thanks Micha,

I had not looked at the TImageList's Wdith and Height properties.  I had
assumed that being a list, it would either not have them or that it would
assume those for the bitmaps put into it (perhaps giving an error if a
bitmap was added that wasn't the same size as those already present).

Thanks,

Ted

 
 
 

1. TimageList (Problem);

What is it with the TimageList componant..
 i have a few 16x16 16 color images in it..
 i want to draw transparent with a TTreeView or any where !!!!>..
it apparently only works one way..
 when adding Bitmaps using the  Add(Bitmap, Bitmap) i need to set Mask
on and i use the
same Bitmap in both, then i also must make sure that the color for
transparcy is White!!!!!!!!!!!!
 this is the only why i can get it to work correct, from there it will
draw on any color surfuce correctly..
 but it was my inpression that any color in the lower left coner would
be the transparent color ?

2. Polygon 'direction'

3. TImageList Problem - Please Help

4. MTV "The Maxx" done in 3DSMAX

5. Resolution Problems with TImageList

6. drawindexedprimitiveUP problem

7. invisble Timagelist problems

8. Max 2.0 Dealer

9. Problems with TImageList

10. TImageList->GetResource problems...

11. TBitmap, TImageList and pf24bit problem

12. TimageList problem

13. Problems w/TImageList (SP2, WinXP)