AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Mathematik, gedrehtes Bild an Rahmen anpassen
Thema durchsuchen
Ansicht
Themen-Optionen

Mathematik, gedrehtes Bild an Rahmen anpassen

Ein Thema von Luckie · begonnen am 12. Dez 2006 · letzter Beitrag vom 20. Feb 2007
 
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#7

Re: Mathematik, gedrehtes Bild an Rahmen anpassen

  Alt 20. Feb 2007, 11:43
Ich bekomme bei dem Code immer noch eine AV:
Delphi-Quellcode:
procedure TForm2.tbbRotateLeftClick(Sender: TObject);

  procedure RotateBitmap(const BitmapOriginal: TBitmap; BitmapRotated: TBitmap; const AngleOfRotation: DOUBLE);
  var
    jRotationAxis : INTEGER;
    iRotationAxis : INTEGER;
    cosTheta : EXTENDED;
    i : INTEGER;
    iOriginal : INTEGER;
    iPrime : INTEGER;
    j : INTEGER;
    jOriginal : INTEGER;
    jPrime : INTEGER;
    RowOriginal : PRGB32Array;
    RowRotated : PRGB32Array;
    sinTheta : EXTENDED;
  begin
    iRotationAxis := BitmapOriginal.Width div 2;
    jRotationAxis := BitmapOriginal.height div 2;
  // Get SIN and COS in single call from math library
    sincos(AngleOfRotation, sinTheta, cosTheta);

// If no math library, then use this:
// sinTheta := SIN(AngleOfRotation);
// cosTheta := COS(AngleOfRotation);

  // Step through each row of rotated image.
    for j := BitmapRotated.Height - 1 downto 0 do
    begin
      RowRotated := BitmapRotated.Scanline[j];
      jPrime := j - jRotationAxis;

      for i := BitmapRotated.Width - 1 downto 0 do
      begin
        iPrime := i - iRotationAxis;
        iOriginal := iRotationAxis + ROUND(iPrime * CosTheta - jPrime * sinTheta);
        jOriginal := jRotationAxis + ROUND(iPrime * sinTheta + jPrime * cosTheta);

      // Make sure (iOriginal, jOriginal) is in BitmapOriginal. If not,
      // assign transparent color to corner points.
        if (iOriginal >= 0) and (iOriginal <= BitmapOriginal.Width - 1) and
          (jOriginal >= 0) and (jOriginal <= BitmapOriginal.Height - 1) then
        begin
        // Assign pixel from rotated space to current pixel in BitmapRotated
          RowOriginal := BitmapOriginal.Scanline[jOriginal];
          RowRotated[i] := RowOriginal[iOriginal]
        end
        else
        begin
          RowRotated[i].R := 0; // assign transparent color
          RowRotated[i].G := 0;
          RowRotated[i].B := 0
        end

      end
    end;
  end;

var
  BmpSrc, BmpDest : TBitmap;
begin
  BmpSrc := TBitmap.Create;
  BmpDest := TBitmap.Create;
  try
    BmpSrc.Width := ImageEnVect1.layers[ImageEnVect1.LayersCurrent].Width;
    BmpSrc.Height := ImageEnVect1.layers[ImageEnVect1.LayersCurrent].Height;
    BmpDest.Width := ImageEnVect1.layers[ImageEnVect1.LayersCurrent].Width;
    BmpDest.Height := ImageEnVect1.layers[ImageEnVect1.LayersCurrent].Height;
    BmpSrc.Assign(ImageEnVect1.Bitmap);
    RotateBitmap(BmpSrc, BmpDest, DegToRad(10));
    ImageEnVect1.Bitmap.Assign(BmpDest);
  finally
    BmpSrc.Free;
    BmpDest.Free;
  end;
end;
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:01 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz