Note that there are some explanatory texts on larger screens.

plurals
  1. POcall c++ class within objective c one
    primarykey
    data
    text
    <p>I wrote c++ class that return uiimage (I made sure that it doesn't return null) and I am trying to call it from objective c obe (uiview based classs) as below code, the problem is that no image be displayed any suggestion to solve that , also when put the code of c++ class at the objective c class the image appear</p> <p>images imaging = new images(); // the c++ class .mm file</p> <pre><code>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-&gt;LoadImage(fullPath)]; viewer.contentMode = UIViewContentModeScaleAspectFit; //holderView.contentMode = UIViewContentModeScaleAspectFit ; [holderView addSubview:viewer]; [self.view addSubview:holderView]; } @catch (NSException * e) { NSLog(@"this was what happened: %a ",e); } </code></pre> <p>this is a part of the loadimage, which create image from the buffer data </p> <p>try{ ...............</p> <p>CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,MyFilter->GetOutput()->GetBufferPointer(), bufferLength, NULL); if(colorSpaceRef == NULL) { NSLog(@"Error allocating color space"); CGDataProviderRelease(provider); } </p> <pre><code> 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-&gt;GetOutput()-&gt;GetBufferPointer(), Width, Height, bitsPerComponent, bytesPerRow, colorSpaceRef, bitmapInfo); } else { context = CGBitmapContextCreate(myimg-&gt;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 &amp; e) { throw(e); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload