ios - The difference between captureImage.image; and [captureImage].image; -
i trying use captureimage.image; in code can explain code mean , correct captureimage.image;
or [captureimage].image;
or [captureimage.image];
i using code .h
iboutlet uipickerview *savetopicker; nsmutablearray *arraygenre; } @property(nonatomic, retain) avcapturestillimageoutput *stillimageoutput; @property (weak, nonatomic) iboutlet uilabel *categorylabel; @property (weak, nonatomic) iboutlet uiview *imagepreview; @property (weak, nonatomic) iboutlet uiview *saveimage; @property (weak, nonatomic) iboutlet uiimageview *captureimage; @property (weak, nonatomic) iboutlet uisegmentedcontrol *cameraswitch; @property (weak, nonatomic) iboutlet uiview *pickerviewcontainer; @property (nonatomic, retain) uiaccelerometer *accelerometer; @property (weak,nonatomic) iboutlet uiscrollview *bgscrollview; - (ibaction)savebutton:(id)sender; - (ibaction)closebutton:(id)sender; - (ibaction)switchcamera:(id)sender; - (ibaction)snapimage:(id)sender;
for implementation file
- (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component{ nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; //fetch category name array used fill picker view nsstring *categoryname= [arraygenre objectatindex:row]; nsstring *fpath = [documentsdirectory stringbyappendingpathcomponent:categoryname]; nsfilemanager *filemanager=[[nsfilemanager alloc]init]; [filemanager createdirectoryatpath:fpath withintermediatedirectories:yes attributes:nil error:nil]; [captureimage.image]; [data writetofile:fpath atomically:yes]; nsdata *data= uiimagepngrepresentation(image); } - (ibaction)snapimage:(id)sender { if (!haveimage) { captureimage.image = nil; //remove old image view captureimage.hidden = no; //show captured image view imagepreview.hidden = yes; //hide live video feed [self capimage]; } else { captureimage.hidden = yes; imagepreview.hidden = no; haveimage = no; } } - (void) capimage { //method capture image avcapturesession video feed avcaptureconnection *videoconnection = nil; (avcaptureconnection *connection in stillimageoutput.connections) { (avcaptureinputport *port in [connection inputports]) { if ([[port mediatype] isequal:avmediatypevideo] ) { videoconnection = connection; break; } } if (videoconnection) { break; } } nslog(@"about request capture from: %@", stillimageoutput); [stillimageoutput capturestillimageasynchronouslyfromconnection:videoconnection completionhandler: ^(cmsamplebufferref imagesamplebuffer, nserror *error) { if (imagesamplebuffer != null) { nsdata *imagedata = [avcapturestillimageoutput jpegstillimagensdatarepresentation:imagesamplebuffer]; [self processimage:[uiimage imagewithdata:imagedata]]; } }]; } - (void) processimage:(uiimage *)image { //process captured image, crop, resize , rotate haveimage = yes; if([uidevice currentdevice].userinterfaceidiom==uiuserinterfaceidiompad) { //device ipad // resize image uigraphicsbeginimagecontext(cgsizemake(768, 1022)); [image drawinrect: cgrectmake(0, 0, 768, 1022)]; uiimage *smallimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); cgrect croprect = cgrectmake(0, 130, 768, 768); cgimageref imageref = cgimagecreatewithimageinrect([smallimage cgimage], croprect); //or use uiimage wherever [captureimage setimage:[uiimage imagewithcgimage:imageref]]; cgimagerelease(imageref); captureimage.hidden = no; }else{ //device iphone // resize image uigraphicsbeginimagecontext(cgsizemake(320, 426)); [image drawinrect: cgrectmake(0, 0, 320, 426)]; uiimage *smallimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); cgrect croprect = cgrectmake(0, 55, 320, 320); cgimageref imageref = cgimagecreatewithimageinrect([smallimage cgimage], croprect); [captureimage setimage:[uiimage imagewithcgimage:imageref]]; cgimagerelease(imageref); } //adjust image orientation based on device orientation if ([[uidevice currentdevice] orientation] == uideviceorientationlandscapeleft) { nslog(@"landscape left image"); [uiview beginanimations:@"rotate" context:nil]; [uiview setanimationduration:0.5]; captureimage.transform = cgaffinetransformmakerotation(degreestoradians(-90)); [uiview commitanimations]; } if ([[uidevice currentdevice] orientation] == uideviceorientationlandscaperight) { nslog(@"landscape right"); [uiview beginanimations:@"rotate" context:nil]; [uiview setanimationduration:0.5]; captureimage.transform = cgaffinetransformmakerotation(degreestoradians(90)); [uiview commitanimations]; } if ([[uidevice currentdevice] orientation] == uideviceorientationportraitupsidedown) { nslog(@"upside down"); [uiview beginanimations:@"rotate" context:nil]; [uiview setanimationduration:0.5]; captureimage.transform = cgaffinetransformmakerotation(degreestoradians(180)); [uiview commitanimations]; } if ([[uidevice currentdevice] orientation] == uideviceorientationportrait) { nslog(@"upside upright"); [uiview beginanimations:@"rotate" context:nil]; [uiview setanimationduration:0.5]; captureimage.transform = cgaffinetransformmakerotation(degreestoradians(0)); [uiview commitanimations]; } }
however getting errors saying expected identifier on first captureimage.image
code , use of undeclared identifier data on the[data writetofile:fpath atomically:yes];
and use of undeclared identifier image in nsdata *data= uiimagepngrepresentation(image);
did wrong?
you give more information on you're trying achieve, , isn't working. answer question: captureimage.image
1 valid syntax of three
edit: see you've updated answer code, it's not clear me captureimage line should do. captureimage.image
calls image method (usually property) on captureimage
object, there's no declaration object.
edit 2: assuming captureimage exists outside of method, last few lines should this:
uiimage *image = captureimage.image; nsdata *data = uiimagepngrepresentation(image); [data writetofile:fpath atomically:yes];
Comments
Post a Comment