Image換圖的問題 |
答題得分者是:jow
|
jason-CDC
一般會員 發表:6 回覆:3 積分:1 註冊:2007-12-05 發送簡訊給我 |
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
jason-CDC
一般會員 發表:6 回覆:3 積分:1 註冊:2007-12-05 發送簡訊給我 |
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
HikaruGo
中階會員 發表:22 回覆:69 積分:88 註冊:2007-12-09 發送簡訊給我 |
|
jow
尊榮會員 發表:66 回覆:751 積分:1253 註冊:2002-03-13 發送簡訊給我 |
直接繪製於Form上, 謹供參考...
[code cpp] //--------------------------------------------------------------------------- #ifndef fMainH #define fMainH //--------------------------------------------------------------------------- #include #include #include #include <Forms.hpp><br />//--------------------------------------------------------------------------- void _draw_(TCanvas* canvas, TRect r, String FileName); //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: void __fastcall FormPaint(TObject *Sender); void __fastcall FormResize(TObject *Sender); private: TTimer* FTimer; void __fastcall SetCurrentIndex(int Value); void __fastcall DO_OnTimer(TObject* Sender); public: int FCurrentIndex; __fastcall TForm1(TComponent* Owner); __property int CurrentIndex = {read=FCurrentIndex, write=SetCurrentIndex}; }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif [/code] [code cpp] //--------------------------------------------------------------------------- #include #pragma hdrstop #include "fMain.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- int MAX_IMAGE_COUNT = 3; void _draw_(TCanvas* canvas, TRect r, String FileName) { if(canvas && FileExists(FileName)){ Graphics::TBitmap* bmp = new Graphics::TBitmap(); try{ bmp->LoadFromFile(FileName); canvas->Lock(); try{ canvas->StretchDraw(r, bmp); } __finally{ canvas->Unlock(); } } __finally{ delete bmp; } } } //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { CurrentIndex = 0;//Initial Picture Current Index FTimer = new TTimer(this); FTimer->Interval = 1000;//間隔: 一秒 FTimer->OnTimer = DO_OnTimer; } //--------------------------------------------------------------------------- void __fastcall TForm1::SetCurrentIndex(int Value) { if(Value != FCurrentIndex){ FCurrentIndex = (Value MAX_IMAGE_COUNT) % MAX_IMAGE_COUNT; Invalidate(); } } //--------------------------------------------------------------------------- void __fastcall TForm1::DO_OnTimer(TObject* Sender) { CurrentIndex = 1; } //--------------------------------------------------------------------------- void __fastcall TForm1::FormPaint(TObject *Sender) { AnsiString fn; fn.sprintf("D:\\Images\\%4.4d.bmp", FCurrentIndex); _draw_(Canvas, ClientRect, fn); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormResize(TObject *Sender) { FormPaint(Sender); } //--------------------------------------------------------------------------- [/code] ===================引 用 jason-CDC 文 章=================== 請問 我有n個圖檔 0001.bmp 0002.bmp~n.bmp 如何讓Image每隔10秒換ㄧ張圖 程式該怎麼寫
編輯記錄
jow 重新編輯於 2007-12-10 16:40:41, 註解 無‧
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |