iphone - ALAsset thumbnail without inward black translucent border -


i have find photos in gallery, [alasset thumbnail] return thumbnail inward black translucent border.

my question is, how can obtain thumbnail without border?

you have lot of options. if need display on screen fake 1 pixel of thumbnail isn't visible. can put uiimageview inside uiview clips bounds.

uiview* view = [[uiview alloc] initwithframe:cgrectmake(0, 0, 200, 200)]; view.backgroundcolor = [uicolor clearcolor]; view.clipstobounds = yes; uiimageview* imgview = [[uiimageview alloc] initwithframe:cgrectmake(-1, -1, 202, 202)]; imgview.image = [asset thumbnail]; [view addsubview:imgview]; 

or better yet, make uiview subclass , override drawrect.

-(void)drawrect:(cgrect)rect {     uiimage* thumb = [asset thumbnail];     [thumb drawinrect:cgrectmake(rect.origin.x-1, rect.origin.y-1, rect.size.width+2, rect.size.height+2)]; } 

or can use aspectratiothumbnail instead , make squared yourself.

uiimageview* imgview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, 200, 200)]; imgview.image = [asset aspectratiothumbnail]; imgview.contentmode = uiviewcontentmodescaleaspectfill; 

or if need crop uiimage reason can this.

uiimage* thumb = [asset thumbnail]; cgrect croprect = cgrectmake(1, 1, thumb.size.width-2, thumb.size.height-2); croprect = cgrectmake(croprect.origin.x*thumb.scale, croprect.origin.y*thumb.scale, croprect.size.height*croprect.scale);         cgimageref imageref = cgimagecreatewithimageinrect([thumb cgimage], croprect); uiimage* result = [uiimage imagewithcgimage:imageref scale:thumb.scale orientation:thumb.imageorientation];  cgimagerelease(imageref); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -