=

Daschmi's Notizblog

RSS Feed

Bilder in iOS auf Breite skallieren unter Beachtung des Seitenverhältnisses

Erstellt in IPhone SDK am 30. September 2013

- (UIImage *)imageWithImage: (UIImage *)sourceImage {

i_width = 640; // Neue Breite für das Bild

float oldWidth = sourceImage.size.width;
float scaleFactor = i_width / oldWidth;

float newHeight = sourceImage.size.height * scaleFactor;
float newWidth = oldWidth * scaleFactor;

UIGraphicsBeginImageContext(CGSizeMake(newWidth, newHeight));
[sourceImage drawInRect:CGRectMake(0, 0, newWidth, newHeight)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return newImage;

}


Bitte genehmigen Sie die Verwendung von Cookies dieser Website! Mehr Informationen

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close