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

向前輩請教:如何把圖片欄位中圖片90度左右轉向,又如知道其長寬是多少

答題得分者是:hagar
zhczm888
一般會員


發表:17
回覆:6
積分:4
註冊:2002-11-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-11-21 15:11:46 IP:61.142.xxx.xxx 未訂閱
同標題
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-11-21 19:26:59 IP:211.21.xxx.xxx 未訂閱
1.參考: The following function I wrote rotates a bitmap 90°to the left.
function SCRotateLeftBitmap(Bitmap : TBitmap) : TBitmap;
var
  x,y : Integer;
  Hoogte, Breedte : Integer;
begin
  Breedte:=Bitmap.Width;
  Hoogte:=Bitmap.Height;
  Result := TBitmap.Create;
  try
    with Result do
    begin
      Width:=Hoogte;
      Height:=Breedte;
      for x:=0 to Breedte-1 do
        for y:=0 to Hoogte-1 do
          Canvas.Pixels[Hoogte-y-1,x]:=Bitmap.Canvas.Pixels[x,y];
    end;
  except
    Result.Free;
    raise;
  end;
end;
The next function rotates a bitmap with every angle, but I never tested it.
function RotateImage(Src : TBitmap; Anglo : Real) : TBitmap;
var
 i, j, W, H : Integer;
  X1, X2, Y1, Y2 : Integer;
  C : TColor;
  Rx, Ry : Integer;
  Side3, FX, FY : Extended;
  SDC, DDC : Integer;
begin
  W := Src.Width;
  H := Src.Height;
 TmpMem.Height := Round(H * 2.5);
 TmpMem.Width := Round(W * 2.5);
  SDC := Src.Canvas.Handle;
  DDC := TmpMem.Canvas.Handle;
  for i := 0 to W - 1 do
   for j := 0 to H - 1 do
    begin
        C := GetPixel(SDC, i, j);
        Side3 := Sqrt(Sqr(i)   Sqr(j));
        SinCos((ArcSin(I / Side3)   Anglo), FX, FY);
        Rx := Round(FX * Side3)   W;
        Ry := Round(FY * Side3)   H;
        if j = 1 then
         begin
       X1 := Rx;
          Y1 := Ry;
          X2 := Rx;
          Y2 := Ry;
          end
        else
          begin
           if Rx < X1 then X1 := Rx;
          if Ry < Y1 then Y1 := Ry;
          if Rx > X2 then X2 := Rx;
          if Ry > Y2 then Y2 := Ry;
          end;
        SetPixel(DDC, Rx , Ry, C);
        end;
  Result := TmpMem;
end;
2.長寬不就 TImage.Width, TImage.Height 嗎? -- Everything I say is a lie.
系統時間:2024-05-15 2:42:06
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!