0

I been trying to convert an UIImage to a matrix or a bitarray in swift but I don`t know how

import UIKit
import PlaygroundSupport

let bgimg = UIImage(named: "IMG_8565.JPG") // The image used as a background
let bgimgview = UIImageView(image: bgimg) // Create the view holding the image
bgimgview.frame = CGRect(x: 0, y: 0, width: 500, height: 500) // The size of the background image

let frontimg = UIImage(named: "spongebob.png") // The image in the foreground
let frontimgview = UIImageView(image: frontimg) // Create the view holding the image
frontimgview.frame = CGRect(x: 100, y: 200, width: 150, height: 150) // The size and position of the front image

bgimgview.addSubview(frontimgview) // Add the front image on top of the background

the last line contains the image and is what i`m trying to change into a matrix or a bitarray

also I know there are similar post but i hardly understand them, so please help me

1

1 Answer 1

0

mb you want just convert your image to the Data?

guard let image = UIImage(named: "IMG_8565.JPG") else { return }
guard let data = image?.jpegData(compressionQuality: 1.0) else { return }

compressionQuality: 1.0 - it's max quality for your image.

Sign up to request clarification or add additional context in comments.

1 Comment

No, I need to convert the UIImage into a matrix to be able to display it as that, a matrix

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.