以下這斷code該如何記憶體歸還呢 |
尚未結案
|
dragonhippopdc
一般會員 發表:45 回覆:51 積分:19 註冊:2005-01-15 發送簡訊給我 |
Byte *ptr2; int x,y; Graphics::TBitmap *Bitmap1; Bitmap1=new Graphics::TBitmap; Bitmap1=Form1->Image3->Picture->Bitmap ; Bitmap1->PixelFormat=pf24bit; for ( y = 0; y < 10; y ) { ptr2 = (Byte *)Bitmap1->ScanLine[y]; for ( x = 0; x < ImageWidth; x ) { ptr2[x*3]=tableBuffer[0][(9-y)*ImageWidth x]; ptr2[x*3 1]=ptr2[x*3]; ptr2[x*3 2]=ptr2[x*3]; } } Bitmap1->Assign(Bitmap1); 請問以上這個Bitmap1要如何歸還呢?我這段code是在一個迴圈中重覆執行的 但是他會不斷的吃記憶體所以請問該歸還? |
JerryKuo
版主 發表:42 回覆:571 積分:322 註冊:2003-03-10 發送簡訊給我 |
引言:Byte *ptr2; int x,y; Graphics::TBitmap *Bitmap1; Bitmap1=new Graphics::TBitmap; Bitmap1=Form1->Image3->Picture->Bitmap ; Bitmap1->PixelFormat=pf24bit; for ( y = 0; y < 10; y ) { ptr2 = (Byte *)Bitmap1->ScanLine[y]; for ( x = 0; x < ImageWidth; x ) { ptr2[x*3]=tableBuffer[0][(9-y)*ImageWidth x]; ptr2[x*3 1]=ptr2[x*3]; ptr2[x*3 2]=ptr2[x*3]; } } Bitmap1->Assign(Bitmap1); delete Bitmap1 請問以上這個Bitmap1要如何歸還呢?我這段code是在一個迴圈中重覆執行的 但是他會不斷的吃記憶體所以請問該歸還? |
brook
資深會員 發表:57 回覆:323 積分:371 註冊:2002-07-12 發送簡訊給我 |
|
dragonhippopdc
一般會員 發表:45 回覆:51 積分:19 註冊:2005-01-15 發送簡訊給我 |
各位大大~很抱歉這個code是我自己改過的~我放上原先我由書上看到的code
Byte *ptr2; int x,y; Graphics::TBitmap *Bitmap1,*Bitmap2; Bitmap2=new Graphics::TBitmap; Bitmap1=Form1->Image4->Picture->Bitmap ; //Bitmap1->PixelFormat=pf24bit; //Bitmap2->PixelFormat=pf24bit; Bitmap2->Assign(Bitmap1); for ( y = 0; y < 20; y ) { ptr2 = (Byte *)Bitmap2->ScanLine[y]; for ( x = 0; x < ImageWidth; x ) { ptr2[x*3]=tempBuffer[(19-y)*ImageWidth x]; ptr2[x*3 1]=ptr2[x*3]; ptr2[x*3 2]=ptr2[x*3]; } } Bitmap1->Assign(Bitmap2); delete Bitmap2;但是因為它一定有同樣的問題所以我才自己改了一下~但是還是一樣~ 請問各位大大以上這個code那邊有問題呢~謝謝各位大大 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |