全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1433
推到 Plurk!
推到 Facebook!

一個利用持續擷取螢幕來取得梯形校正功能 但延遲太長時間 希望達到即時呈現校正功能 希望各位先進提供幫助 謝謝

尚未結案
kfr1234
一般會員


發表:1
回覆:1
積分:0
註冊:2008-10-30

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-10-30 22:45:37 IP:123.204.xxx.xxx 訂閱

[code cpp]
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "fstream.h"

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
Graphics::TBitmap *temp1 = new Graphics::TBitmap();
Graphics::TBitmap *pBitmap = new Graphics::TBitmap();

double aaak,bbbk,k;
int i,j;
int a[800][600],b[800][600];
TColor DrawColor;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
for(j=0;j<600;j ){ //600
for(i=0;i<800;i ) { //800
aaak=i 0.278582298*j;
bbbk=i*(3.91874E-20) j*1.128494393;
k=i*(-2.51535E-17) j*0.000691418 1;
a[i][j]=aaak/k;
b[i][j]=bbbk/k;
}
}
HDC ScreenDC=GetDC(0);
pBitmap->Width = 800 ;
pBitmap->Height = 600 ;
StretchBlt(pBitmap->Canvas->Handle,
0,
0,
800,
600,
ScreenDC,
0,
0,
800,
600,
SRCCOPY
);

temp1->Assign(pBitmap) ;
temp1->LoadFromFile("Black.bmp");

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
HDC ScreenDC=GetDC(0);
pBitmap->Width = 800 ;
pBitmap->Height = 600 ;
StretchBlt(pBitmap->Canvas->Handle,
0,
0,
800,
600,
ScreenDC,
0,
0,
800,
600,
SRCCOPY
);

for(j=0;j<600;j ){ //600
for(i=0;i<800;i ) { //800
temp1->Canvas->Pixels[a[i][j]][b[i][j]] =pBitmap->Canvas->Pixels[i][j];
}
}

Image1->Picture->Assign(temp1);
ReleaseDC(0,ScreenDC);
}
//---------------------------------------------------------------------------
[/code]
------
各位先進大家好
我是新進人員
請多多指教
編輯記錄
kfr1234 重新編輯於 2008-10-30 22:46:25, 註解 無‧
taishyang
站務副站長


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-10-30 23:33:37 IP:218.168.xxx.xxx 訂閱
用ScanLine的方式會比Pixels[][]快非常多,
ScanLine的方式站上有很多範例可以參考
kfr1234
一般會員


發表:1
回覆:1
積分:0
註冊:2008-10-30

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-10-30 23:59:15 IP:123.204.xxx.xxx 訂閱
因為要指定特殊的對應點來供對應
雖然顏色跑掉了(這問題有待解決...有知道解決的也順便提供方法 感恩)
但如此改用ScanLine 但是速度卻不見提升

[code cpp]
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "fstream.h"

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
Graphics::TBitmap *temp1 = new Graphics::TBitmap();
Graphics::TBitmap *pBitmap = new Graphics::TBitmap();
unsigned char *ptr;
unsigned char *ptr1;
unsigned char *ptr2;
unsigned char *ptr3;

double aaak,bbbk,k;
int i,j;
int a[490000],b[490000];
//int a[800][600],b[800][600];
TColor DrawColor;
int sss=0;
int sssk=0;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
for(j=0;j<600;j ){ //600
for(i=0;i<800;i ) { //800
aaak=i 0.278582298*j;
bbbk=i*(3.91874E-20) j*1.128494393;
k=i*(-2.51535E-17) j*0.000691418 1;
// a[i][j]=aaak/k;
// b[i][j]=bbbk/k;
a[sssk]=aaak/k;
b[sssk]=bbbk/k;
sssk ;
}
}
HDC ScreenDC=GetDC(0);
pBitmap->Width = 800 ;
pBitmap->Height = 600 ;
StretchBlt(pBitmap->Canvas->Handle,
0,
0,
800,
600,
ScreenDC,
0,
0,
800,
600,
SRCCOPY
);

temp1->Assign(pBitmap) ;
temp1->LoadFromFile("Black.bmp");

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
HDC ScreenDC=GetDC(0);
pBitmap->Width = 800 ;
pBitmap->Height = 600 ;
StretchBlt(pBitmap->Canvas->Handle,
0,
0,
800,
600,
ScreenDC,
0,
0,
800,
600,
SRCCOPY
);

//for(j=0;j<600;j ){ //600
// for(i=0;i<800;i ) { //800
//temp1->Canvas->Pixels[a[i][j]][b[i][j]] =pBitmap->Canvas->Pixels[i][j];
// }
// }
sss=0;
for(j=0;j<600;j ){ //600

ptr3 =(byte *)pBitmap->ScanLine[j];
for(i=0;i<800;i ) { //800
ptr2=(byte *)temp1->ScanLine[b[sss]];
ptr2[a[sss]*3]= ptr3[i*3];
ptr2[a[sss]*3 1]=ptr3[i*3 1];
ptr2[a[sss]*3 2]=ptr3[i*3 2];
sss ;

}}
Image1->Picture->Assign(temp1);
ReleaseDC(0,ScreenDC);
}
//---------------------------------------------------------------------------
[/code]
------
各位先進大家好
我是新進人員
請多多指教
編輯記錄
kfr1234 重新編輯於 2008-10-31 00:00:17, 註解 無‧
系統時間:2024-04-25 17:50:58
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!