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

图像反转

答題得分者是:wameng
小丫123
初階會員


發表:85
回覆:62
積分:29
註冊:2004-08-31

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-09 15:51:14 IP:218.65.xxx.xxx 未訂閱
本人做了一个图像翻转的程序,运行后image2没有显示的结果,程序没有报错,恳请各位前辈帮我看看错在哪里?  
 var
  i,j,h:integer;
  bmp,temp:Tbitmap;    begin
  bmp:=Tbitmap.Create;
  temp:=Tbitmap.Create;
  bmp.Assign(image1.Picture.Bitmap );
  h :=bmp.Height;
  for j:=0 to bmp.Height -1       do
  begin
      for i:=0 to bmp.Height-1 do
      begin
       temp.Canvas.Pixels[i,j]:=bmp.Canvas.Pixels[i,h-j];
      end;
  end;      image2.Picture.Bitmap.Assign(temp);
  temp.free;
  bmp.free;
  end;
研二的女生
wameng
版主


發表:31
回覆:1336
積分:1188
註冊:2004-09-16

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-04-09 16:57:14 IP:219.81.xxx.xxx 未訂閱
問題很簡單。 因為你根本沒有定義 Temp 的寬度與長度。 另外 BMP 根本不需要建立。{浪費資源}
procedure TForm1.Button1Click(Sender: TObject);
var
  i,j,h:integer;
  bmp,temp:Tbitmap;
begin
  BMP  := image1.Picture.Bitmap;
  temp := TBitmap.Create;
  Try
    h    := Bmp.Height;
    Temp.Height := Bmp.Height;
    Temp.Width  := BMP.Width;        for j:=0 to bmp.Height -1       do
    begin
        for i:=0 to bmp.Height-1 do
        begin
         temp.Canvas.Pixels[i,j]:=bmp.Canvas.Pixels[i,h-j];
        end;
    end;
    image2.Picture.bitmap.Assign(temp);
  Finally
    temp.free;
  end;
end;
系統時間:2024-06-27 0:13:41
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!