[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppVclTImageList

(C++ VCL) TImageList

Component for storing TImages.

//Forward declaration
namespace Controls { class TImageList; }
//Header file
  1. include <Controls.hpp>


Example to add two TImages at runtime and draw them to the Canvas of Form1.

//Note: Create a 1x1 bitmap image (e.g. by using Paint) and put it
//in the program's folder!
//Also, put a TImageList Component on the main TForm
  1. include <memory> //For std::auto_ptr
//Create TImageList const int width = 256; const int height = 256; ImageList1->Width = width; ImageList1->Height = height; //Create pImage std::auto_ptr<TImage> pImage(new TImage(0)); pImage->Picture->LoadFromFile("1x1.bmp"); pImage->Picture->Bitmap->Width = width; pImage->Picture->Bitmap->Height = height; pImage->Width = width; pImage->Height = height; //Draw first image in own scope { for (int y=0; y!=pImage->Height; ++y) { unsigned char * pLine = static_cast<unsigned char *>( pImage->Picture->Bitmap->ScanLine[y]); for (int x=0; x!=pImage->Width; ++x) { pLine[x*3+0]= x ; //Blue pLine[x*3+1]= y ; //Green pLine[x*3+2]= x+y; //Red } } ImageList1->Add(pImage->Picture->Bitmap,0); } //Draw second image in own scope { for (int y=0; y!=pImage->Height; ++y) { unsigned char * pLine = static_cast<unsigned char *>( pImage->Picture->Bitmap->ScanLine[y]); for (int x=0; x!=pImage->Width; ++x) { pLine[x*3+0]= x+y; //Blue pLine[x*3+1]= x ; //Green pLine[x*3+2]= y ; //Red } } ImageList1->Add(pImage->Picture->Bitmap,0); } ImageList1->Draw(this->Canvas,0,0,0,true); ImageList1->Draw(this->Canvas,width+1,0,1,true);


Code links

'TImageList' links



last edited (December 31, 2006) by bilderbikkel, Number of views: 1730, Current Rev: 5 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.