線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1807
推到 Plurk!
推到 Facebook!

Timage元件動態放大後, 竟然無法繪圖, 怎麼辦?

答題得分者是:william
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-04-08 13:02:03 IP:61.61.xxx.xxx 未訂閱
不知是否為Timage元件的bug? 我將一個image之width及height設定為640及480. 但是在程式中根據使用者動作將該image放大或縮小. 然後進行繪圖. 我發現即使在image已放大超過640X480, 但在超過640及480的部份, 無法顯示所繪圖形. 請問這是什麼原因? gogowin
------
gogowin
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-04-08 13:50:31 IP:218.16.xxx.xxx 未訂閱
我想你動態改變的,只是 TImage.Picture.Bitmap 裡的 width 及 height 而沒有改 TImage 本身的 width 及 height 罷,所以你的 TImage 之遠都是 640 X 480 大小。 若不是這個因素,可否 Post 出你改變 Image 大小的 Code 。
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-04-08 14:35:53 IP:61.61.xxx.xxx 未訂閱
我有改變Timage的height及width. 我的程式有點複雜,上下壘了三個image. 程式碼如下: inc(gscale_index); gscale:=gscales[gscale_index];//gscale是縮放倍率參數 new_width:= round(videoW*gscale); new_HEIGHT:= round(videoH*gscale); image_spot.height:=NEW_HEIGHT; image_spot.width:=NEW_width; image_graph.height:=NEW_HEIGHT; image_graph.width:=NEW_width; image_spot.Canvas.TextOut(100,new_height-10,'image_spot'); image_graph.Canvas.TextOut(100,new_height-30,'image_graph'); 不過我在image1上面有另外一個image_cross, 其大小不變.仍保持640X480. 其transparent屬性是true. 其作用就好像是一個窗戶一樣. 而且在image_spot下面還有一個image_graph.大小跟image_spot同時變動. 結果很神奇的是image_graph可以顯示文字,但是image_spot不能在640X480的範圍之外 繪製文字或圖形... 不知道我還漏了什麼因子沒有描述? gogowin
------
gogowin
Justmade
版主


發表:94
回覆:1934
積分:2030
註冊:2003-03-12

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-04-08 15:00:01 IP:218.16.xxx.xxx 未訂閱
要解決問題要先將問題簡單化,你可先試試單一 TImage 對超過原始設定的大小是否可顯示(我試的是可以的)。 再來就完全套用你的程式碼但除去另外兩個 TImage 以減少變數。 若也可行再逐一加入另外兩個 TImage 看那時起出現問題。
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-04-08 15:01:08 IP:61.61.xxx.xxx 未訂閱
補充一點: 因為image放大後,會被image_cross遮住,所以我用下列程式碼來將image_spot及image1上移: procedure TFormHunter.ToolButton1Click(Sender: TObject); begin image_graph.top:=image_graph.top-20; image_spot.top:=image_graph.top; end; gogowin
------
gogowin
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-04-08 15:05:03 IP:147.8.xxx.xxx 未訂閱
Here is part of the srouce of TImage:    
function TImage.GetCanvas: TCanvas;
var
  Bitmap: TBitmap;
begin
  if Picture.Graphic = nil then
  begin
        Bitmap := TBitmap.Create;
        try
          Bitmap.Width := Width;
          Bitmap.Height := Height;
          Picture.Graphic := Bitmap;
        finally
          Bitmap.Free;
        end;
  end;
  if Picture.Graphic is TBitmap then
        Result := TBitmap(Picture.Graphic).Canvas
  else
        raise EInvalidOperation.Create(SImageCanvasNeedsBitmap);
end;
When you first draw on the canvas, an internal picture is created as the same size of the image. Later when you resize the image, the picture is not resized and hence you cannot draw outside the size of the previous region. So a proper procedure is to set both size of the image and its bitmap, e.g. image_spot.height := NEW_HEIGHT; image_spot.width := NEW_width; image_spot.Picture.Bitmap.height := NEW_HEIGHT; image_spot.Picture.Bitmap.width := NEW_width;
help
一般會員


發表:12
回覆:54
積分:13
註冊:2002-06-14

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-04-08 16:19:32 IP:61.61.xxx.xxx 未訂閱
感謝JUSTMADE及William,    原來是image.picture.bitmap.height出了問題.沒有自動跟著設定.    Justmade回答時,我竟沒聽懂. 後來william一回答, 我才懂.    很猶豫好像應該給justmade得分. 但是是william大大讓我通了.    謝謝兩位了.
------
gogowin
系統時間:2024-05-16 13:24:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!