How do I manipulate a dynamic array of variable sized Delphi TBitmaps?
Posted on 2007-10-08
I need to know if it is possible to manipulate a dynamic array of tbitmaps of variable sizes. ( Because ot the varrying size, I can't use to TimageList)
This is the code I propose to use to add and remove elements from the array. Can anyone confirm that this will work - or correct any problems or definately tell me this can't be safely done at all. I'd like some "Expert" opinions before I try using this code. Because I'd like a good answer and if this or something like it will work I need to get this code out to my client today I'm spending 500 points to be shared among those who give me good information about this.
TBitmapArray = array of TBitmap;
BMParray : TBitmapArray;
procedure newBMP(ba: TBitmapArray; x,y,w,h: integer);
procedure killBMP(ba: TBitmapArray; index: integer);
procedure T_form.newBMP(ba: TBitmapArray; x,y,w,h: integer);
DC : HDC;
DC := GetDC (GetDesktopWindow) ;
// The actual populating of the bitmaps is more complicate than the following
// but they will be variable size and this will suffice as an example
BitBlt(BMParray[n].Canvas.Handle, 0, 0, BMParray[n].Width, BMParray[n].Height, DC, x, y, SRCCOPY) ;
ReleaseDC (GetDesktopWindow, DC) ;
procedure T_form.killBMP(ba: TBitmapArray; index: Integer);
if (index<=High(ba)) and (index>=Low(ba)) then
// is this the proper order? to do this first before the SetLength?
// it's the only way that makes sense to me
if index<>High(ba) then
// this is the part I'm most concerned about...
System.Move(ba[Index+1], ba[Index], (Length(ba)-Index-1)*SizeOf(TBitmap)+1);
SetLength(ba, Length(ba) - 1) ;