canvas does not allow drawing |
答題得分者是:anpino
|
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; } szCommand = AThread->Connection->ReadInteger(true); AnsiString split_Num = IntToStr(szCommand).SubString(1,1); Graphics::TBitmap *bmp_Source bmp_Source = new Graphics::TBitmap; TMemoryStream *msBuf = new TMemoryStream; TJPEGImage *jpeg = new TJPEGImage; //若該頻道沒有接Camera則不傳送 /*if(!is_Transfer[NetCHCount]){ AThread->Connection->WriteInteger(-1,true); delete msBuf; msBuf = NULL; delete jpeg; jpeg = NULL; delete bmp_Source; bmp_Source = NULL; AThread->Connection->Tag ; if (AThread->Connection->Tag >= 16) AThread->Connection->Tag = 0; return; } */ AThread->Connection->Tag = NetCHCount; //NetCHCount = CHNumber[AThread->Connection->Tag]; switch(AThread->Connection->Tag) { case 0: bmp_Source->Assign(NetBmp1); break; case 1: bmp_Source->Assign(NetBmp2); break; case 2: bmp_Source->Assign(NetBmp3); break; case 3: bmp_Source->Assign(NetBmp4); break; case 4: bmp_Source->Assign(NetBmp5); break; case 5: bmp_Source->Assign(NetBmp6); break; case 6: bmp_Source->Assign(NetBmp7); break; case 7: bmp_Source->Assign(NetBmp8); break; case 8: bmp_Source->Assign(NetBmp9); break; case 9: bmp_Source->Assign(NetBmp10); break; case 10: bmp_Source->Assign(NetBmp11); break; case 11: bmp_Source->Assign(NetBmp12); break; case 12: bmp_Source->Assign(NetBmp13); break; case 13: bmp_Source->Assign(NetBmp14); break; case 14: bmp_Source->Assign(NetBmp15); break; case 15: bmp_Source->Assign(NetBmp16); break; } jpeg->Assign(bmp_Source); jpeg->CompressionQuality = 72; jpeg->Compress(); jpeg->SaveToStream(msBuf); delete jpeg; jpeg = NULL; delete bmp_Source; bmp_Source = NULL; if (split_Num == "1"){ if (AThread->Connection->Tag != StrToInt(IntToStr(szCommand).SubString(2,3))){ AThread->Connection->WriteInteger(-1,true); delete msBuf; msBuf = 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 != AThread->Connection->Tag && CH2 != AThread->Connection->Tag && CH3 != AThread->Connection->Tag && CH4 != AThread->Connection->Tag){ AThread->Connection->WriteInteger(-1,true); delete msBuf; msBuf = 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 != AThread->Connection->Tag && CH2 != AThread->Connection->Tag && CH3 != AThread->Connection->Tag && CH4 != AThread->Connection->Tag && CH5!=AThread->Connection->Tag && CH6!=AThread->Connection->Tag && CH7!=AThread->Connection->Tag && CH8!= AThread->Connection->Tag && CH9!= AThread->Connection->Tag) { AThread->Connection->WriteInteger(-1,true); delete msBuf; msBuf = NULL; return; } } //jpeg->Assign(bmp_Dest); if (szCommand != 0){ msBuf->Position=0; AThread->Connection->WriteInteger(AThread->Connection->Tag,true); AThread->Connection->WriteStream(msBuf,true,true); // transfer data stream to internet } else{ delete msBuf; msBuf = NULL; AThread->Connection->Disconnect(); return; } delete msBuf; msBuf = NULL; } }catch(const EIdConnClosedGracefully &eCloseErr) { delete msBuf; msBuf = NULL; AThread->Connection->Disconnect(); return; }發表人 - taishyang 於 2004/01/05 20:51:52 |
海星
高階會員 發表:41 回覆:217 積分:106 註冊:2003-01-09 發送簡訊給我 |
|
jason_cyl329
高階會員 發表:123 回覆:155 積分:105 註冊:2003-05-26 發送簡訊給我 |
|
anpino
版主 發表:31 回覆:477 積分:231 註冊:2003-01-02 發送簡訊給我 |
canvas does not allow drawing 的錯誤會在兩個以上的threads同時讓一個Canvas執行繪圖動作時發生, 例如2個threads同時呼叫Image1->Canvas->Ellipse(). Draw()...等等繪圖函式。 請檢查所有的Canvas, 並讓繪圖動作只由一個thread 來做。 --------------------------------------
數學系是內功很強(邏輯/分析) 資工系是招式很多(程式技巧) 就像令狐沖url="http://anpino.begin.8d8d.com"
|
paul67
一般會員 發表:20 回覆:18 積分:7 註冊:2003-03-17 發送簡訊給我 |
|
anpino
版主 發表:31 回覆:477 積分:231 註冊:2003-01-02 發送簡訊給我 |
|
paul67
一般會員 發表:20 回覆:18 積分:7 註冊:2003-03-17 發送簡訊給我 |
|
anpino
版主 發表:31 回覆:477 積分:231 註冊:2003-01-02 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |