This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public unsafe static class Accelerate | |
{ | |
[StructLayout(LayoutKind.Sequential)] | |
public struct DSPComplex | |
{ | |
public float real; | |
public float imag; | |
} | |
[StructLayout(LayoutKind.Sequential)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CVPixelBuffer GetBuffer(CGImage image) | |
{ | |
const int _bitsPerPixel = 8; | |
nint width = (nint)image.Width; | |
nint height = (nint)image.Height; | |
nint bytesPerRow = (nint)image.BytesPerRow; | |
var bufferData = new byte[height * bytesPerRow]; | |
var colorspace = image.ColorSpace; | |
var bmi = image.BitmapInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSData JpegData(this CGImage cgImage, float compressionQuality) | |
{ | |
var data = NSMutableData.Create(); | |
var idst = CGImageDestination.Create(data, "UTTypeJPEG", 1, null); | |
if (idst != null) | |
{ | |
var props = NSDictionary.FromObjectsAndKeys( | |
new[] { NSNumber.FromFloat(compressionQuality) }, | |
new[] { CGImageDestinationOptionsKeys.LossyCompressionQuality } |