Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert MfArray to UnsafeMutablePointer<Float32>? #54

Open
vtn98 opened this issue Jun 28, 2024 · 1 comment
Open

Convert MfArray to UnsafeMutablePointer<Float32>? #54

vtn98 opened this issue Jun 28, 2024 · 1 comment

Comments

@vtn98
Copy link

vtn98 commented Jun 28, 2024

Hi @jjjkkkjjj
I have created an MfArray from UImage, now I want to convert it to UnsafeMutablePointer? in swift. How can I do that? Please help me. Thank you

@jjjkkkjjj
Copy link
Owner

When you convert UIImage into MfArray, you can access the pointer by withUnsafeMutableStartPointer

public func withUnsafeMutableStartPointer<T, R>(datatype: T.Type, _ body: (UnsafeMutablePointer<T>) throws -> R) rethrows -> R{

How about like this?

var image = Matft.image.cgimage2mfarray(self.swapImageView.image!.cgImage!)
image.withUnsafeMutableStartPointer(datatype: Float.Type) {
   ptr in
   // note: ptr is UnsageMutablePointer<Float>
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants