Resizing image - Cocoa - MAC OS X -
i trying write small library captures screen shot , stores image on disk.
i able screen shot working , image stored on disk. now, not able resize image based on specified height , width. here code snippet:
int imagewidth = 200; int imageheight = 200; cfstringref keys[2]; cftyperef values[2]; keys[0] = kcgimagepropertydpiheight; values[0] = cfnumbercreate(null, kcfnumberinttype, &imageheight); keys[1] = kcgimagepropertydpiwidth; values[1] = cfnumbercreate(null, kcfnumberinttype, &imagewidth); cfdictionaryref options = null; options = cfdictionarycreate( null, (const void **)keys, (const void **)values, 2, &kcftypedictionarykeycallbacks, &kcftypedictionaryvaluecallbacks); // set image in image destination `image' // optional properties specified in saved properties dict. cgimagedestinationaddimage(dest, imageref, options); bool success = cgimagedestinationfinalize(dest); nsassert( success != 0, @"image not written successfully"); please let me know if doing wrong.
not sure, there lot of things going on without seeing how making cgimageref, tough see problem. have tried use nsimage, super easy work with.
nsimage * img = [[nsimage alloc] initwithcgimage:imageref size:nszerosize]; [img setsize: nsmakesize(imagewidth,imageheight)]; //do img; [img release]; failing set breakpoints, , make sure think valid, is.
Comments
Post a Comment