• Wieder einmal haben uns unsere Apfeltalker tolle Fotos zur Abstimmung eingesandt. Welches ist Euer Favorit? Stimmt mit ab! Hier geht es zur Abstimmung --> Klick
  • Es ist bereits Apfeltalk-Tradition und wir möchten sie auch in diesem Jahr fortsetzen: Unser Apfeltalk-Weihnachtslogo-Wettbewerb hat begonnen! Gestaltet für uns das Weihnachtsbanner, das im Monat Dezember bis zum Weihnachtsfest unsere Webseite schmücken soll. Lasst Eurer Kreativität freien Lauf! Hier geht es zum Wettbewerb --> 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);