objective c - How to compress an Image taken by the camera in iphone sdk? -


i getting list of contacts address book in contacts have images taken camera huge in size.i displaying contacts along images in 3x3 rows , columns format.the problem due huge size of images taking time load images.can suggest me how compress them. tried compress them in way:

if ([imagedata length] > 0) {     int len = [imagedata length];     if(len > 9000)     {         uiimage *theimage =  [uiimage imagewithdata:imagedata];         imagedata = uiimagejpegrepresentation(theimage,0.5);         printf("\n image data length in condition...%d",[imagedata length]);         imageviewl.image = [uiimage imagewithdata:imagedata];     }     else     {         imageviewl.image = [uiimage imagewithdata:imagedata];        } } 

eventhough taking time load.

anyone's appreciated.

thanks all, monish.

you can resize image captured iphone camera using following lines of code

-(uiimage *)scaleimage:(uiimage *)image tosize:(cgsize)newsize {       uigraphicsbeginimagecontext(newsize);       [image drawinrect:cgrectmake(0, 0, newsize.width, newsize.height)];       uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext();       uigraphicsendimagecontext();         return newimage;   } 

and call method this

uiimage *image = [self scaleimage:your image tosize:cgsizemake(320.0,480.0)]; 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -