canvas does not allow drawing |
尚未結案
|
paul67
一般會員 發表:20 回覆:18 積分:7 註冊:2003-03-17 發送簡訊給我 |
請問各位前輩..
弟目前寫了一段由Server端傳圖到client端做遠端視訊,但連線連個一天時卻會發生 canvas does not allow drawing的錯誤訊息。請問什麼原因會導致這個錯
誤出現呢。。以下是我網路部分程式碼
try{
if (AThread->Connection->Connected()){
if(APClosed){
szCommand = AThread->Connection->ReadInteger(true);
AThread->Connection->WriteInteger(-100,true);
return;
}
short int NetCHNum;
szCommand = AThread->Connection->ReadInteger(true);
AnsiString split_Num = IntToStr(szCommand).SubString(1,1);
//Graphics::TBitmap *bmp_Source = new Graphics::TBitmap;
TMemoryStream *msBuf1,*msBuf2,*msBuf3,*msBuf4;
TJPEGImage *jpeg1,*jpeg2,*jpeg3,*jpeg4;
switch(AThread->Connection->Tag)
{
case 1:
msBuf1 = new TMemoryStream;
jpeg1 = new TJPEGImage;
break;
case 2:
msBuf2 = new TMemoryStream;
jpeg2 = new TJPEGImage;
break;
case 3:
msBuf3 = new TMemoryStream;
jpeg3 = new TJPEGImage;
break;
case 4:
msBuf4 = new TMemoryStream;
jpeg4 = new TJPEGImage;
break;
} NetCHNum = NetCHCount; switch(NetCHNum)
{
case 0:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp1);
break;
case 2:
jpeg2->Assign(NetBmp1);
break;
case 3:
jpeg3->Assign(NetBmp1);
break;
case 4:
jpeg4->Assign(NetBmp1);
break;
}
break;
case 1:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp2);
break;
case 2:
jpeg2->Assign(NetBmp2);
break;
case 3:
jpeg3->Assign(NetBmp2);
break;
case 4:
jpeg4->Assign(NetBmp2);
break;
}
break;
case 2:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp3);
break;
case 2:
jpeg2->Assign(NetBmp3);
break;
case 3:
jpeg3->Assign(NetBmp3);
break;
case 4:
jpeg4->Assign(NetBmp3);
break;
}
break;
case 3:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp4);
break;
case 2:
jpeg2->Assign(NetBmp4);
break;
case 3:
jpeg3->Assign(NetBmp4);
break;
case 4:
jpeg4->Assign(NetBmp4);
break;
}
break;
case 4:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp5);
break;
case 2:
jpeg2->Assign(NetBmp5);
break;
case 3:
jpeg3->Assign(NetBmp5);
break;
case 4:
jpeg4->Assign(NetBmp5);
break;
}
break;
case 5:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp6);
break;
case 2:
jpeg2->Assign(NetBmp6);
break;
case 3:
jpeg3->Assign(NetBmp6);
break;
case 4:
jpeg4->Assign(NetBmp6);
break;
}
break;
case 6:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp7);
break;
case 2:
jpeg2->Assign(NetBmp7);
break;
case 3:
jpeg3->Assign(NetBmp7);
break;
case 4:
jpeg4->Assign(NetBmp7);
break;
}
break;
case 7:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp8);
break;
case 2:
jpeg2->Assign(NetBmp8);
break;
case 3:
jpeg3->Assign(NetBmp8);
break;
case 4:
jpeg4->Assign(NetBmp8);
break;
}
break;
case 8:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp9);
break;
case 2:
jpeg2->Assign(NetBmp9);
break;
case 3:
jpeg3->Assign(NetBmp9);
break;
case 4:
jpeg4->Assign(NetBmp9);
break;
} break;
case 9:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp10);
break;
case 2:
jpeg2->Assign(NetBmp10);
break;
case 3:
jpeg3->Assign(NetBmp10);
break;
case 4:
jpeg4->Assign(NetBmp10);
break;
}
break;
case 10:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp11);
break;
case 2:
jpeg2->Assign(NetBmp11);
break;
case 3:
jpeg3->Assign(NetBmp11);
break;
case 4:
jpeg4->Assign(NetBmp11);
break;
}
break;
case 11:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp12);
break;
case 2:
jpeg2->Assign(NetBmp12);
break;
case 3:
jpeg3->Assign(NetBmp12);
break;
case 4:
jpeg4->Assign(NetBmp12);
break;
}
break;
case 12:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp13);
break;
case 2:
jpeg2->Assign(NetBmp13);
break;
case 3:
jpeg3->Assign(NetBmp13);
break;
case 4:
jpeg4->Assign(NetBmp13);
break;
}
break;
case 13:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp14);
break;
case 2:
jpeg2->Assign(NetBmp14);
break;
case 3:
jpeg3->Assign(NetBmp14);
break;
case 4:
jpeg4->Assign(NetBmp14);
break;
}
break;
case 14:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp15);
break;
case 2:
jpeg2->Assign(NetBmp15);
break;
case 3:
jpeg3->Assign(NetBmp15);
break;
case 4:
jpeg4->Assign(NetBmp15);
break;
}
break;
case 15:
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->Assign(NetBmp16);
break;
case 2:
jpeg2->Assign(NetBmp16);
break;
case 3:
jpeg3->Assign(NetBmp16);
break;
case 4:
jpeg4->Assign(NetBmp16);
break;
} break;
}
//jpeg->Assign(NetBmp1);
switch(AThread->Connection->Tag)
{
case 1:
jpeg1->CompressionQuality = 72;
jpeg1->Compress();
jpeg1->SaveToStream(msBuf1);
delete jpeg1;
break;
case 2:
jpeg2->CompressionQuality = 72;
jpeg2->Compress();
jpeg2->SaveToStream(msBuf2);
delete jpeg2;
break;
case 3:
jpeg3->CompressionQuality = 72;
jpeg3->Compress();
jpeg3->SaveToStream(msBuf3);
delete jpeg3;
break;
case 4:
jpeg4->CompressionQuality = 72;
jpeg4->Compress();
jpeg4->SaveToStream(msBuf4);
delete jpeg4;
break;
}
jpeg1 = NULL;
jpeg2 = NULL;
jpeg3 = NULL;
jpeg4 = NULL; //delete bmp_Source;
//bmp_Source = NULL; if (split_Num == "1"){
if (NetCHNum != StrToInt(IntToStr(szCommand).SubString(2,3))){
AThread->Connection->WriteInteger(-1,true);
switch(AThread->Connection->Tag)
{
case 1:
delete msBuf1;
break;
case 2:
delete msBuf2;
break;
case 3:
delete msBuf3;
break;
case 4:
delete msBuf4;
break;
}
msBuf1 = NULL;
msBuf2 = NULL;
msBuf3 = NULL;
msBuf4 = NULL;
return;
}
}
else if (split_Num == "4"){
CH1 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 0) % 16);
CH2 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 1) % 16);
CH3 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 2) % 16);
CH4 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 3) % 16);
if (CH1 != NetCHNum && CH2 != NetCHNum && CH3 != NetCHNum && CH4 != NetCHNum){
AThread->Connection->WriteInteger(-1,true);
switch(AThread->Connection->Tag)
{
case 1:
delete msBuf1;
break;
case 2:
delete msBuf2;
break;
case 3:
delete msBuf3;
break;
case 4:
delete msBuf4;
break;
}
msBuf1 = NULL;
msBuf2 = NULL;
msBuf3 = NULL;
msBuf4 = NULL;
return;
}
}
else if (split_Num == "9"){
CH1 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 0) % 16);
CH2 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 1) % 16);
CH3 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 2) % 16);
CH4 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 3) % 16);
CH5 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 4) % 16);
CH6 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 5) % 16);
CH7 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 6) % 16);
CH8 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 7) % 16);
CH9 = ((StrToInt(IntToStr(szCommand).SubString(2,3)) 8) % 16); if (CH1 != NetCHNum && CH2 != NetCHNum && CH3 != NetCHNum && CH4 != NetCHNum && CH5!=NetCHNum
&& CH6!=NetCHNum && CH7!=NetCHNum && CH8!= NetCHNum && CH9!= NetCHNum)
{
AThread->Connection->WriteInteger(-1,true);
switch(AThread->Connection->Tag)
{
case 1:
delete msBuf1;
break;
case 2:
delete msBuf2;
break;
case 3:
delete msBuf3;
break;
case 4:
delete msBuf4;
break;
}
msBuf1 = NULL;
msBuf2 = NULL;
msBuf3 = NULL;
msBuf4 = NULL;
return;
} } //jpeg->Assign(bmp_Dest); if (szCommand != 0){
AThread->Connection->WriteInteger(NetCHNum,true);
switch(AThread->Connection->Tag)
{
case 1:
msBuf1->Position=0;
AThread->Connection->WriteStream(msBuf1,true,true); // transfer data stream to internet
break;
case 2:
msBuf2->Position=0;
AThread->Connection->WriteStream(msBuf2,true,true); // transfer data stream to internet
break;
case 3:
msBuf3->Position=0;
AThread->Connection->WriteStream(msBuf3,true,true); // transfer data stream to internet
break;
case 4:
msBuf4->Position=0;
AThread->Connection->WriteStream(msBuf4,true,true); // transfer data stream to internet
break;
} }
else{
switch(AThread->Connection->Tag)
{
case 1:
delete msBuf1;
break;
case 2:
delete msBuf2;
break;
case 3:
delete msBuf3;
break;
case 4:
delete msBuf4;
break;
}
msBuf1 = NULL;
msBuf2 = NULL;
msBuf3 = NULL;
msBuf4 = NULL;
AThread->Connection->Disconnect();
return;
} switch(AThread->Connection->Tag)
{
case 1:
delete msBuf1;
break;
case 2:
delete msBuf2;
break;
case 3:
delete msBuf3;
break;
case 4:
delete msBuf4;
break;
}
msBuf1 = NULL;
msBuf2 = NULL;
msBuf3 = NULL;
msBuf4 = NULL; }
}catch(const EIdConnClosedGracefully &eCloseErr){
//}catch(const EInvalidOperation &eCloseErr)
//}catch(...){ AThread->Connection->Disconnect();
return;
}
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
http://www.delphifaq.com/fq/q4053.shtml
Msg 'Canvas does not allow drawing'
Q: What does the error message 'Canvas does not allow drawing' mean?
A:
1.you may have run out of resources, which means a new DC cannot be
allocated. Usually this is a result of not freeing unused DCs or other
objects
2.you are attempting to draw to an device context that is not yet valid. Such as in the create constructor of a component.
3.you are trying to draw on a canvas while your last draw-operation has not finished yet. In this case you can use Canvas.Lock or Canvas.TryLock to fix it.
小弟認為第 1. 點的原因比較大
原程式看不出有將 jpeg1 Free 的地方
(也有可能是小弟看不懂 C++ )
另外, 您貼錯版了, 本版是 > ---
>@>
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |