Rotating UIImage in Swift

Swift 5 Solution I wrote Pixel SDK which offers a more powerful solution to this problem, otherwise here is the simplest solution: extension UIImage { func rotate(radians: Float) -> UIImage? { var newSize = CGRect(origin: CGPoint.zero, size: self.size).applying(CGAffineTransform(rotationAngle: CGFloat(radians))).size // Trim off the extremely small float value to prevent core graphics from rounding it up … Read more

How do I get the color of a pixel in a UIImage with Swift?

A bit of searching leads me here since I was facing the similar problem. You code works fine. The problem might be raised from your image. Code: //On the top of your swift extension UIImage { func getPixelColor(pos: CGPoint) -> UIColor { let pixelData = CGDataProviderCopyData(CGImageGetDataProvider(self.CGImage)) let data: UnsafePointer<UInt8> = CFDataGetBytePtr(pixelData) let pixelInfo: Int = … Read more

Get Pixel color of UIImage

Try this very simple code: I used to detect a wall in my maze game (the only info that I need is the alpha channel, but I included the code to get the other colors for you): – (BOOL)isWallPixel:(UIImage *)image xCoordinate:(int)x yCoordinate:(int)y { CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage)); const UInt8* data = CFDataGetBytePtr(pixelData); int pixelInfo = … Read more

How to set image for bar button with swift?

I have achieved that programatically with this code: import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() //create a new button let button: UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton //set image for button button.setImage(UIImage(named: “fb.png”), forState: UIControlState.Normal) //add function for button button.addTarget(self, action: “fbButtonPressed”, forControlEvents: UIControlEvents.TouchUpInside) //set frame button.frame = CGRectMake(0, 0, 53, 31) … Read more

How to Convert UIImage to CIImage and vice versa

CIImage *ciImage = [UIImage imageNamed:@”test.png”].CIImage; UIImage *uiImage = [[UIImage alloc] initWithCIImage:ciImage]; To fix the case where myUIImage.CIImage returns nil like [UIImageView image], you can instead do [CIImage imageWithCGImage:myUIImage.CGImage] – Dylan Hand Swift version: let ciImage = UIImage(named: “test.png”)!.ciImage let uiImage = UIImage(ciImage: ciImage) To fix the case where myUIImage.ciImage returns nil like you can instead … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)