• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Die Bildungsoffensive hier im Forum geht weiter! Jetzt sollen Kreativität und technische Möglichkeiten einen neue Dimension erreichen. Das Thema in diesem Monat lautet - Verkehrte Welt - Hier geht es lang --> Klick

Verzerren einer UIImageView

MoFuRo

Jamba
Registriert
10.06.10
Beiträge
55
Hallo zusammen,

ich will ein Bild, das ich in eine UIImageView lade, verzerren. Ist das irgendwie über imagview.transform möglich? Ich hab es mal so versucht:

Code:
imageView.transform = CGAffineTransformMake(0, 0, 1, 0, 0, 0);

Das Bild wird dann aber nicht angezeigt und es kommt der Fehler:

CGAffineTransformInvert: singular matrix.

Das ganze soll wie auf diesem Bild aussehen:

matrix_skew_image.jpg


Wäre cool wenn mir da jemand helfen könnte.

Thx ;-)
 
Hallo,

habe jetzt herausgefunden das es so aussehen muss:

Code:
transform = CGAffineTransformMake(1, 0, angle, 1, 0, 0);

Wie bekomme ich es jetzt aber hin das ich das Bild auch vergrößere? Das ganze passiert übrigens beim touch auf den Bildschirm.
 
Da es sich um eine Matrix handelt solltest du mal google anwerfen.

Matrix hat ja was mit Mathe zu tun ;) Es gibt s.g. Eiheitsmatrizen die bei bestimmten Werten Das Urbild (also deine View) in eine Neue Abbildung schaffen (verzerrte View)

Die Doku gibt da ne Menge schon her.

CGAffineTransform
A structure for holding an affine transformation matrix.

struct CGAffineTransform {
CGFloat a;
CGFloat b;
CGFloat c;
CGFloat d;
CGFloat tx;
CGFloat ty;
};
typedef struct CGAffineTransform CGAffineTransform;
Fields
a
The entry at position [1,1] in the matrix.
b
The entry at position [1,2] in the matrix.
c
The entry at position [2,1] in the matrix.
d
The entry at position [2,2] in the matrix.
tx
The entry at position [3,1] in the matrix.
ty
The entry at position [3,2] in the matrix.
Discussion
In Quartz 2D, an affine transformation matrix is used to rotate, scale, translate, or skew the objects you draw in a graphics context. The CGAffineTransform type provides functions for creating, concatenating, and applying affine transformations.

In Quartz, affine transforms are represented by a 3 by 3 matrix:


Because the third column is always (0,0,1), the CGAffineTransform data structure contains values for only the first two columns.

Conceptually, a Quartz affine transform multiplies a row vector representing each point (x,y) in your drawing by this matrix, producing a vector that represents the corresponding point (x’,y’):


Wie bekomme ich es jetzt aber hin das ich das Bild auch vergrößere? Das ganze passiert übrigens beim touch auf den Bildschirm.

Nach Skaliermatrix suchen, oder Werte bei transform = CGAffineTransformMake(1, 0, angle, 1, 0, 0); neuschreiben also aus 1 mach 2 und 0 bleibt 0

CGAffineTransformMake(2, 0, angle, 2, 0, 0);