lundi 23 mars 2015

vImageBoxConvolve_ARGB8888 in swift

We have this basic form of vImageBoxConvolve_ARGB8888 API in swift.



vImageBoxConvolve_ARGB8888(src: UnsafePointer<vImage_Buffer>, dest: UnsafePointer<vImage_Buffer>, tempBuffer: UnsafeMutablePointer<Void>, srcOffsetToROI_X: vImagePixelCount, srcOffsetToROI_Y: vImagePixelCount, kernel_height: UInt32, kernel_width: UInt32, backgroundColor: UnsafeMutablePointer<UInt8>, flags: vImage_Flags)


I am in a situation where i want to add values to this function like this.



vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend)


I managed to add first two parameters, and last parameter. I have no idea how can i pass UnsafeMutablePointer value as NULL and other values as zeros to this function parameters. I tried several methods, none of them working properly. If you guys have any idea about this, please help me out here. Thanks in advance.


I tried with the first answer code, by using that also it is not working.



var effectOutBuffer : vImage_Buffer = vImage_Buffer(data: CGBitmapContextGetData(effectOutContext), width: CGBitmapContextGetWidth(effectOutContext), height: CGBitmapContextGetHeight(effectOutContext), rowBytes: CGBitmapContextGetBytesPerRow(effectOutContext))

var effectInBuffer : vImage_Buffer = vImage_Buffer(data: CGBitmapContextGetData(effectInContext), width: CGBitmapContextGetWidth(effectInContext), height: CGBitmapContextGetHeight(effectInContext), rowBytes: CGBitmapContextGetBytesPerRow(effectInContext))


vImageBoxConvolve_ARGB8888(&effectInBuffer, dest: &effectOutBuffer, tempBuffer: nil as UnsafeMutablePointer<Void>, srcOffsetToROI_X: vImagePixelCount( 0 ), srcOffsetToROI_Y: vImagePixelCount( 0 ), kernel_height: radius, kernel_width: radius, backgroundColor: nil as UnsafeMutablePointer<UInt8>, kvImageEdgeExtend)


// Still shows error, saying that cant invoke init with argument type(... all parametrs)




Aucun commentaire:

Enregistrer un commentaire