Board index » cppbuilder » Imagelist
|
strabger
CBuilder Developer |
|
strabger
CBuilder Developer |
Imagelist2003-08-06 10:29:06 PM cppbuilder99 I'm a beginner with cpp builder. I've this problem: i'm not able to add icons in my imagelist. I can't find the directory containing the icons. Can someone help me? My c++ Builder is the 6 version. thnk's. Claudio |
| viana
CBuilder Developer |
2004-06-10 03:59:44 AM
Re:Imagelist
hi,
i'm trying to use a BMP from a TImagelist to put it in the glyph property of a button. the code is like this : imagelist1.getbitmap(1,button1.glyph); the code works, but the image in the button never is exact the same as the image in the imagelist. there is some differences in color. so the question is : how to get a bitmap in the imagelist and it looks exact as in the imagelist ? thanks in advance |
| Ma Xiaoguang
CBuilder Developer |
2004-08-03 09:33:46 AM
Re:Imagelist
Hi, viana:
I think you should to use a TSpeedButton instead of TButton. I loaded the bitmap from TImageList was successful. My codes like this: procedure TForm1.Button1Click(Sender: TObject); var Bmp: TBitmap; begin Bmp := TBitmap.Create; try ImageList1.GetBitmap(0, Bmp); { Maybe you need the following line. The transparent color should be same as the Icon in TImageList. } Bmp.TransprarentColor := clWhite; SpeedButton1.Glyph.Assign(Bmp); finally Bmp.Free; end; end; The codes above was worked with Delphi 5. Best regards. Xiaoguang "viana" < XXXX@XXXXX.COM >wrote in message Quote
{smallsort} |
| SVC
CBuilder Developer |
2005-05-18 05:44:29 AM
Re:Imagelist
Greetings,
I am trying to load an image (for splash) based on a macro, i.e.: #ifdef TEST Image1->Picture->LoadFromFile(".\\splash\\Test_Splash.jpg"); #else Image1->Picture->LoadFromFile(".\\splash\\Real_Splash.jpg"); #endif This method requires having the actual jpeg file available otherwise an exception is thrown. Is there a way of including the graphical files in the executable and accessing through an index? Thanks, S. |
| JD
CBuilder Developer |
2005-05-18 06:01:07 AM
Re:Imagelist
"SVC" < XXXX@XXXXX.COM >wrote:
Quote
Quoteand accessing through an index? ~ JD |
| Remy Lebeau (TeamB)
CBuilder Developer |
2005-05-18 06:02:38 AM
Re:Imagelist
"SVC" < XXXX@XXXXX.COM >wrote in message
QuoteThis method requires having the actual jpeg file available otherwise QuoteIs there a way of including the graphical files in the executable images, you can instantiate an instance of TJPEGImage, then call its LoadFromStream() method, using a TResourceStream to access the image data from the application's resources, and then finally assign the TJPEGImage to TPicture's Graphic property. For example: TResourceStream *Stream = new TResourceStream(HInstance, #ifdef TEST FirstID, #else SecondID, #endif RT_RCDATA); try { TJPEGImage *JPG = new TJPEGImage; try { JPG->LoadFromStream(Stream); Image1->Picture->Graphic = JPG; } __finally { delete JPG; } } __finally { delete Stream; } Do note that the above makes multiple copies of the JPG image, since assigning the Graphic property makes a copy of the graphic rather than taking ownership of it. If you don't want the extra copy, you can do the following instead: TResourceStream *Stream = new TResourceStream(HInstance, #ifdef TEST FirstID, #else SecondID, #endif RT_RCDATA); try { TJPEGImage *JPG = new TJPEGImage; try { // yes, this is assigning a blank image. This is to force the Graphic // property to be the correct class type before then loading the // image data into it... Image1->Picture->Graphic = JPG; } __finally { delete JPG; } Image1->Picture->Graphic->LoadFromStream(Stream); } __finally { delete Stream; } Gambit |
| Remy Lebeau (TeamB)
CBuilder Developer |
2005-05-18 07:41:25 AM
Re:Imagelist
"JD" < XXXX@XXXXX.COM >wrote in message
QuoteLook at LoadFromResourceID |
| wgy
CBuilder Developer |
2005-05-18 09:56:18 PM
Re:Imagelist
I guess that he meant the ship the exe without the image files. You can load
image at design time into image list, and then reference the images by their index. But the exe file size is much bigger than JPG file bundle with the exe because TImagelist store image in bmp mode. It doesn't matter since you installation will zip the file anyway. "SVC" < XXXX@XXXXX.COM >wrote in message QuoteGreetings, |
