Einzelnen Beitrag anzeigen

Peter666

Registriert seit: 11. Aug 2007
357 Beiträge
 
#11

Re: Bitmap perspektivisch in 3D drehen

  Alt 12. Aug 2007, 12:29
Hat jemand eine schnelle Lösung für einen PlgBltersatz der die Textur in der z-Achse kleiner werden lässt? Meine Variante baut auf WarpBlt auf:
Delphi-Quellcode:
procedure CopySourceToDest(hdcDst: HDC; ul, ur, lr, ll: TPoint;
  hdcSrc: HDC; x1, y1, x2, y2: LONGINT);
var tm, lm, rm, bm, m: TPoint;
  mx, my: Longint;
  cr: COLORREF;

begin
       // Does the destination area specify a single pixel?
  if ((abs(ul.x - ur.x) < THRESH) and
    (abs(ul.x - lr.x) < THRESH) and
    (abs(ul.x - ll.x) < THRESH) and
    (abs(ul.y - ur.y) < THRESH) and
    (abs(ul.y - lr.y) < THRESH) and
    (abs(ul.y - ll.y) < THRESH)) then
  begin
    cr := GetPixel(hdcSrc, (x1 shr SHIFTS), (y1 shr SHIFTS));
    SetPixel(hdcDst, (ul.x shr SHIFTS), (ul.y shr SHIFTS), cr);
  end else
  begin // No // Quarter the source and the destination, and then recurse.
    tm.x := (ul.x + ur.x) shr 1;
    tm.y := (ul.y + ur.y) shr 1; bm.x := (ll.x + lr.x) shr 1; bm.y := (ll.y + lr.y) shr 1;
    lm.x := (ul.x + ll.x) shr 1; lm.y := (ul.y + ll.y) shr 1; rm.x := (ur.x + lr.x) shr 1;
    rm.y := (ur.y + lr.y) shr 1;
    m.x := (tm.x + bm.x) shr 1; m.y := (tm.y + bm.y) shr 1;
    mx := (x1 + x2) shr 1; my := (y1 + y2) shr 1;
    CopySourceToDest(hdcDst, ul, tm, m, lm, hdcSrc, x1, y1, mx, my);
    CopySourceToDest(hdcDst, tm, ur, rm, m, hdcSrc, mx, y1, x2, my);
    CopySourceToDest(hdcDst, m, rm, lr, bm, hdcSrc, mx, my, x2, y2);
    CopySourceToDest(hdcDst, lm, m, bm, ll, hdcSrc, x1, my, mx, y2);
  end;
end;

procedure WarpBlt(hdcDst: HDC; ul, ur, lr, ll: TPoint; hdcSrc: HDC; x1, y1, x2, y2: Longint);
begin
  ul.x := ul.x shl SHIFTS;
  ul.y := ul.y shl SHIFTS;
  ur.x := ur.x shl SHIFTS;
  ur.y := ur.y shl SHIFTS;

  lr.x := lr.x shl SHIFTS;
  lr.y := lr.y shl SHIFTS;
  ll.x := ll.x shl SHIFTS;
  ll.y := ll.y shl SHIFTS;

  x1 := x1 shl SHIFTS; y1 := y1 shl SHIFTS; x2 := x2 shl SHIFTS; y2 := y2 shl SHIFTS;

  CopySourceToDest(hdcDst, ul, ur, lr, ll, hdcSrc, x1, y1, x2, y2);
end;
und ist zu langsam. Selbst, wenn man GetPixel und Setpixel durch direkte Speicherzugriffe beschleunigt, ist die Geschwindigkeit inakzeptabel

Peter

[edit=SirThornberry]Delphi-Tags gesetzt - Mfg, SirThornberry[/edit]
  Mit Zitat antworten Zitat