I wrote a C ++ class that returns uiimage (I made sure that it does not return null), and I'm trying to call it from object c obe (classes based on uiview) as shown below, the problem is that the image is not any suggestion for solving this issue is displayed, and also, if you put the code of the C ++ class in the object class c, an image will appear
image images = new images (); // C ++ file of class .mm
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *fullPath = [[paths lastObject] stringByAppendingPathComponent:ImageFileName]; NSLog(fullPath); @try { UIView* holderView = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height)]; viewer = [[UIImageView alloc] initWithFrame:[holderView frame]]; [viewer setImage:imaging->LoadImage(fullPath)]; viewer.contentMode = UIViewContentModeScaleAspectFit;
This is the part of the boot image that creates the image from the buffer data.
try {...............
CGDataProviderRef provider = CGDataProviderCreateWithData (NULL, MyFilter-> GetOutput () → GetBufferPointer (), bufferLength, NULL); if (colorSpaceRef == NULL) {NSLog (@ "Error allocating color space"); CGDataProviderRelease (provider); }
CGImageRef iref = CGImageCreate(Width,Height,bitsPerComponent,bitsPerPixel,bytesPerRow, colorSpaceRef,bitmapInfo,provider,NULL,YES,renderingIntent); CGContextRef context = NULL; if ((Comptype==itk::ImageIOBase::SHORT)||(Comptype==itk::ImageIOBase::USHORT)) { context = CGBitmapContextCreate(MyFilter->GetOutput()->GetBufferPointer(), Width, Height, bitsPerComponent, bytesPerRow, colorSpaceRef, bitmapInfo); } else { context = CGBitmapContextCreate(myimg->GetBufferPointer(), Width, Height, bitsPerComponent, bytesPerRow, colorSpaceRef, bitmapInfo); } if(context == NULL) { NSLog(@"Error context not created"); } //Create the UIImage to be displayed UIImage * uiimage = nil; if (context) { CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, Width, Height), iref); CGImageRef imageRef = CGBitmapContextCreateImage(context); //if([UIImage respondsToSelector:@selector(imageWithCGImage:scale:orientation:)]) { //float scale = [[UIScreen mainScreen] scale]; //uiimage = [UIImage imageWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp]; //} else { uiimage = [UIImage imageWithCGImage:imageRef]; //} CGImageRelease(imageRef); CGContextRelease(context); } CGColorSpaceRelease(colorSpaceRef); CGImageRelease(iref); CGDataProviderRelease(provider); return uiimage; //return uiimage; } catch (itk::ExceptionObject & e) { throw(e); }