C#C# vuforia.image.pixels couvrent à iOS CIImage ou CGImage
private Vuforia.Image QCARoutput;
QCARoutput = CameraDevice.Instance.GetCameraImage(Vuforia.Image.PIXEL_FORMAT.RGB888);
_iOS_sendData(QCARoutput.Pixels, QCARoutput.Pixels.length);
iOS
void _iOS_sendData(const char** ptrSrc, const int srcLength) {
NSData *imageData = [NSData dataWithBytes:(const void *)ptrSrc length:(sizeof(unsigned char) * srcLength)];
CIImage *ciimg = [CIImage imageWithData:imageData];
[delegateObject decodeWithQRcode:ciimg complete:^(NSString *result) {
NSLog(@"%@",result);
}];
}
Je wannted pour obtenir Vuforia.image.pixels qui est l'octet [] . Puis envoyez à la couverture iOS à CIImage, mais ciimage est null. Comment puis-je couvrir ce byte [] à l'objet CIImage?
====== ====== Updata C#
[DllImport("__Internal")]
private static extern void _iOS_sendData_ResultBlock(System.IntPtr ptrSrc, int srcLength);
//=================================================
QCARoutput = CameraDevice.Instance.GetCameraImage(Vuforia.Image.PIXEL_FORMAT.RGB888);
IntPtr unmanagedPointer = Marshal.AllocHGlobal(QCARoutput.Pixels.Length);
Marshal.Copy(QCARoutput.Pixels, 0, unmanagedPointer, QCARoutput.Pixels.Length);
// Call unmanaged code
Marshal.FreeHGlobal(unmanagedPointer);
_iOS_sendData_ResultBlock(unmanagedPointer, QCARoutput.Pixels.Length);
====== Updata Objective-C ======
void _iOS_sendData_ResultBlock(Byte *ptrSrc, const int srcLength, iOSUnityCallBack callback) {
NSData *imageData = [NSData dataWithBytes:ptrSrc length:(sizeof(unsigned char) * srcLength)];
CIImage *ciimg = [CIImage imageWithData:imageData];
if (ciimg == nil) {
NSLog(@"the ciimage is nil ,stop");
return;
}
}
Je fais un changement. Ça ne marche pas.
De plus, si OP veut modifier le tableau du côté natif, le tableau doit être épinglé en C# en premier afin que GC ne se déplace pas. Si ce n'est pas fait, il y aura des plantages aléatoires. – Programmer
@Nika Kasradze J'ai écrit du code comme vous le dites, ça ne marche pas. Ai-je fait une erreur sur Byte * à NSData? Codes mis à jour. – ChokWah