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

為什麼我看不到圖

尚未結案
thjan65
一般會員


發表:2
回覆:2
積分:0
註冊:2005-06-25

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-06-25 17:05:22 IP:59.115.xxx.xxx 未訂閱
以下是我的code,目的是從檔案讀取ascii hex值,再顯示成bitmap.  可是為什麼執行以後,只看到form而沒有image?    
bitmap5=new Graphics::TBitmap;
int t1;
        if( OpenDialog1->Execute() == True ) {
           strcpy(dat_file, OpenDialog1->FileName.c_str());
           FILE *fn_1 = fopen(dat_file,"r");
           while ((fscanf(fn_1, "%2x ", &t1)) != EOF){
              bitmap5->Canvas->Pixels[j][i] = TColor(RGB(t1, t1, t1));
              if (j<255) j  ;
              else {
                 j=0;
                 if (i<255) i  ;
              }
           }
           fclose(fn_1);
           .....
           .....
           Form6->Image1->Picture->Bitmap = bitmap5;
           Form6->Image1->Visible = True;
           Form6->Show();
        }
        else {
           ShowMessage("File can't be open");
        }
}    
taishyang
站務副站長


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-06-27 14:38:09 IP:210.68.xxx.xxx 未訂閱
您好: 您要指定bitmap5的寬,高與PixelFormat才行
thjan65
一般會員


發表:2
回覆:2
積分:0
註冊:2005-06-25

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-06-27 15:07:42 IP:61.217.xxx.xxx 未訂閱
Sorry: I have define the following things.
    Form6->Image1->Width = 256;
    Form6->Image1->Height = 256;
Now I add the following code
    Form6->Image1->Picture->Bitmap->Width = 256;
    Form6->Image1->Picture->Bitmap->Height = 256;
Thank you.
taishyang
站務副站長


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-06-27 15:23:13 IP:210.68.xxx.xxx 未訂閱
您好: 我指的是bitmap5而不是Form6->Image1
thjan65
一般會員


發表:2
回覆:2
積分:0
註冊:2005-06-25

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-06-27 15:31:29 IP:61.217.xxx.xxx 未訂閱
謝謝, 已改好,如下:
        bitmap5=new Graphics::TBitmap;
        bitmap5->PixelFormat=pf8bit;
        bitmap5->Width=256;
        bitmap5->Height=256;
        int t1;
        i=0; j=0;
        if( OpenDialog1->Execute() == True ) {
           strcpy(dat_file, OpenDialog1->FileName.c_str());
           FILE *fn_1 = fopen(dat_file,"r");
           while ((fscanf(fn_1, "%2x ", &t1)) != EOF){
              bitmap5->Canvas->Pixels[j][i] = RGB(t1, t1, t1);
              if (j<255) j  ;
              else {
                 j=0;
                 if (i<255) i  ;
              }
           }
           fclose(fn_1);
           Form6->Width = 300;
           Form6->Height = 300;
           Form6->Caption = dat_file;
           Form6->Image1->Width = 256;
           Form6->Image1->Height = 256;
           Form6->Image1->Center = True;
           Form6->Image1->Picture->Bitmap = bitmap5;
           Form6->Show();
發表人 - thjan65 於 2005/06/27 16:04:45
系統時間:2024-05-06 4:10:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!