線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1783
推到 Plurk!
推到 Facebook!

Image換圖的問題

答題得分者是:jow
jason-CDC
一般會員


發表:6
回覆:3
積分:1
註冊:2007-12-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-12-10 15:48:25 IP:125.233.xxx.xxx 訂閱
請問
我有n個圖檔
0001.bmp 0002.bmp~n.bmp
如何讓Image每隔10秒換ㄧ張圖
程式該怎麼寫
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-12-10 16:05:27 IP:122.124.xxx.xxx 訂閱
可將您測試的程式碼PO上來讓前輩們看看問題在哪^_^
jason-CDC
一般會員


發表:6
回覆:3
積分:1
註冊:2007-12-05

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-12-10 16:11:15 IP:125.233.xxx.xxx 訂閱

===================引 用 taishyang 文 章===================
可將您測試的程式碼PO上來讓前輩們看看問題在哪^_^



對不起
我是個新手
只是有這樣的構想
但是不知道如何著手寫程式

taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#4 引用回覆 回覆 發表時間:2007-12-10 16:18:41 IP:122.124.xxx.xxx 訂閱
1.用TTimer元件,interval設為10秒
2.在Timer的OnTimer事件中用TImage元件讀取圖檔
檔名第一次為0001.bmp 第二次為0002.bmp...

HikaruGo
中階會員


發表:22
回覆:69
積分:88
註冊:2007-12-09

發送簡訊給我
#5 引用回覆 回覆 發表時間:2007-12-10 16:32:12 IP:203.70.xxx.xxx 訂閱
.NET   不用寫程式 @@~    
[code xml]
http://schemas.microsoft.com/winfx/2006/xaml/presentation">




AutoReverse="True" RepeatBehavior="Forever"/>







[/code]
jow
尊榮會員


發表:66
回覆:751
積分:1253
註冊:2002-03-13

發送簡訊給我
#6 引用回覆 回覆 發表時間:2007-12-10 16:37:26 IP:210.66.xxx.xxx 訂閱
直接繪製於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, 註解 無‧
系統時間:2024-04-26 3:18:06
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!