Timage元件動態放大後, 竟然無法繪圖, 怎麼辦? |
答題得分者是:william
|
help
一般會員 發表:12 回覆:54 積分:13 註冊:2002-06-14 發送簡訊給我 |
|
Justmade
版主 發表:94 回覆:1934 積分:2030 註冊:2003-03-12 發送簡訊給我 |
|
help
一般會員 發表:12 回覆:54 積分:13 註冊:2002-06-14 發送簡訊給我 |
我有改變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 發送簡訊給我 |
|
help
一般會員 發表:12 回覆:54 積分:13 註冊:2002-06-14 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
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 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |