C++ Builder 參考手冊 ? Vcl::Graphics ? TPicture
TPicture 可以包含一個從 TGraphic 繼承過來的圖片,例如 TBitmap、TGIFImage、TIcon、TJPEGImage、TPngImage 等
- 簡介
- 成員
屬性
方法
事件
一. TPicture 簡介
- 繼承關(guān)系:
System::TObject
?╙ System::Classes::TPersistent
???┗ System::Classes::TInterfacedPersistent
?????└ Vcl::Graphics::TPicture - 頭文件:
#include <Vcl.Graphics.hpp> - 命名空間:
Vcl::Graphics - TPicture 可以包含一個從 TGraphic 繼承過來的圖片,例如 TBitmap、TGIFImage、TIcon、TJPEGImage、TPngImage 等
- 如果 TPicture 包含一個 TBitmap,Bitmap 屬性為這個位圖;
- 如果 TPicture 包含一個 TIcon,Icon 屬性為這個圖標(biāo);
- 如果 TPicture 包含一個 TMetafile,Metafile 屬性為這個圖片;
- 如果 TPicture 包含一個從 TGraphic 繼承過來的圖片,例如 TBitmap、TGIFImage、TIcon、TJPEGImage、TPngImage、TMetafile 等,Graphic 屬性就是這個圖片,可以用 dynamic_cast 轉(zhuǎn)為對應(yīng)類型的對象指針。所以 Graphic 可以作為一個通用的屬性,當(dāng)需要顯示的時候,只要把 Graphic 屬性作為參數(shù) Draw 或 StretchDraw 到畫布上就可以了。
二. TPicture 成員
1. TPicture 屬性
| 屬性 | 類型 | 說明 |
|---|---|---|
| public: | ? | ? |
| Bitmap | TBitmap * | TPicture 包含的 TBitmap 位圖 |
| Graphic | TGraphic * | TPicture 包含的從 TGraphic 繼承過來的圖片 |
| Height | int | 圖像的原始高度 (pixels) |
| Icon | TIcon * | TPicture 包含的 TIcon 圖標(biāo) |
| Metafile | TMetafile * | TPicture 包含的 TMetafile 圖片 |
| PictureAdapter | _di_IChangeNotifier | 圖片的 OLE 接口 |
| Width | int | 圖像的原始寬度 (pixels) |
2. TPicture 方法
| 方法 | 說明 |
|---|---|
| public: | ? |
| Assign | 把 Source 里面的圖像數(shù)據(jù)賦值 (或格式轉(zhuǎn)換) 到當(dāng)前圖像數(shù)據(jù), 重載了 TPersistent 的 Assign 方法 |
| LoadFromClipboardFormat | 從剪貼板加載圖像數(shù)據(jù) |
| LoadFromFile | 從文件加載圖片 |
| LoadFromStream | 從流加載圖像 |
| operator () | 類型轉(zhuǎn)換操作符,轉(zhuǎn)為 _di_IStreamPersist |
| RegisterClipboardFormat | 添加從 TGraphic 繼承的類和剪貼板格式對應(yīng)的關(guān)聯(lián) |
| RegisterFileFormat | 添加從 TGraphic 繼承的類和文件名后綴的關(guān)聯(lián) |
| RegisterFileFormatRes | 添加從 TGraphic 繼承的類和從資源獲取的文件的關(guān)聯(lián) |
| SaveToClipboardFormat | 把當(dāng)前的圖像數(shù)據(jù)轉(zhuǎn)為剪貼板格式的數(shù)據(jù), 可以把這些數(shù)據(jù)放入剪貼板 |
| SaveToFile | 保存圖片到文件 |
| SaveToStream | 把當(dāng)前圖像保存到流 |
| SupportsClipboardFormat | 返回剪貼板格式是否支持 |
| TPicture | 構(gòu)造函數(shù) |
| ~TPicture | 析構(gòu)函數(shù) |
| UnregisterGraphicClass | 解除從 TGraphic 繼承的類和文件名后綴、剪貼板格式等的關(guān)聯(lián) |
| protected: | |
| AssignTo | 把當(dāng)前圖像內(nèi)容賦值 (或格式轉(zhuǎn)換) 到 Dest 的圖像數(shù)據(jù), 重載了 TPersistent 的 Assign 方法 |
| Changed | 當(dāng)圖像數(shù)據(jù)被修改的時候,會自動調(diào)用 Changed 方法 |
| DefineProperties | 把非 __published: 屬性和數(shù)據(jù)存入流中, 重載了 TPersistent 的 DefineProperties 方法 |
| FindGraphicClass | 在加載或保存圖像時調(diào)用這個方法,用于判斷格式是否支持 |
| Progress | 當(dāng)圖像改變時,會調(diào)用這個方法來觸發(fā) OnProgress 事件 |
| TInterfacedPersistent:: | 從 System::Classes::TInterfacedPersistent 繼承過來的 |
| public: | 從 System::Classes::TInterfacedPersistent 繼承過來的 |
| AfterConstruction | 在構(gòu)造函數(shù)結(jié)束的時候自動調(diào)用 |
| operator _di_IInterface | 類型轉(zhuǎn)換操作符,轉(zhuǎn)為 _di_IInterface 類型 |
| QueryInterface | 返回當(dāng)前組件所支持的 COM 接口的引用 |
| TInterfacedPersistent | 構(gòu)造函數(shù) |
| ~TInterfacedPersistent | 析構(gòu)函數(shù) |
| protected: | ? |
| _AddRef | 調(diào)用 COM 接口增加引用計數(shù) |
| _Release | 調(diào)用 COM 接口減少引用計數(shù) / 銷毀對象 |
| TPersistent:: | 從 System::Classes::TPersistent 繼承過來的 |
| public: | 從 System::Classes::TPersistent 繼承過來的 |
| GetNamePath | 返回在 Object Inspector 屬性面板里面的名稱 |
| TPersistent | 構(gòu)造函數(shù) |
| ~TPersistent | 析構(gòu)函數(shù) |
| protected: | 從 System::Classes::TPersistent 繼承過來的 |
| GetOwner | 返回對象的擁有者 |
| TObject:: | 從 System::TObject 繼承過來的 |
| public: | 從 System::TObject 繼承過來的 |
| BeforeDestruction | 在執(zhí)行析構(gòu)函數(shù)之前自動調(diào)用 |
| ClassInfo | 返回運行時類型信息表 (RTTI table) |
| ClassName | 獲取類名,不包含命名空間的類名字符串 |
| ClassNameIs | 判斷類名是否為參數(shù)指定的字符串 |
| ClassParent | 返回父類的類型信息 |
| ClassType | 返回類的類型信息 |
| CleanupInstance | 清除長字符串、Variants、接口變量等 |
| DefaultHandler | 默認(rèn)的消息處理 |
| Dispatch | 處理消息的函數(shù) |
| DisposeOf | 強制銷毀對象 |
| Equals | 比較當(dāng)前對象和 Obj 對象是否相同 |
| FieldAddress | 通過成員名稱返回成員的地址 |
| Free | 銷毀對象 (Delphi) |
| FreeInstance | 釋放 NewInstance 分配的內(nèi)存 |
| GetInterface | 獲取指定的接口 |
| GetInterfaceEntry | 獲取接口項目 |
| GetInterfaceTable | 獲取接口表 |
| GetHashCode | 返回對象的 hash 值 |
| InheritsFrom | 當(dāng)前對象的類是否從 AClass 繼承過來的 |
| InitInstance | 初始化成員,給他們清零 |
| InstanceSize | 返回給實例數(shù)據(jù)分配內(nèi)存需要多少字節(jié)數(shù) |
| MethodAddress | 通過名稱返方法的地址 |
| MethodName | 通過方法的地址返回名稱 |
| NewInstance | 給實例分配內(nèi)存,并且返回新的實例的地址 |
| QualifiedClassName | 返回包含命名空間的類名 |
| SafeCallException | 處理異常的函數(shù) |
| ToString | 轉(zhuǎn)為字符串 |
| UnitName | 返回類所在的命名空間 |
| UnitScope | 返回類所在的命名空間 |
3. TPicture 事件
| 事件 | 說明 |
|---|---|
| public: | ? |
| OnChange | 當(dāng)加載的圖像發(fā)生變化時產(chǎn)生的事件 |
| OnFindGraphicClass | 在加載或保存圖像時產(chǎn)生這個事件,用于判斷格式是否支持 |
| OnProgress | 當(dāng)加載、存儲、轉(zhuǎn)換的過程中,會產(chǎn)生這個事件 |
參考:
- Vcl::Graphics::TGraphic
- System::Classes::TInterfacedPersistent
- System::Classes::TPersistent
- System::TObject
- VCL 類繼承關(guān)系
C++ Builder 參考手冊 ? Vcl::Graphics ? TPicture