image - AlamofireImage GrayImageEffect -


i make request image view url whit alamofireimage. revice image want convert image in grayscale. write simple class transform image in gray scale how transform image form alamofire gray scale. try method don´t work

            cell.imagem.af_setimagewithurlrequest(self.imagerequest(artwork.thumbnail), placeholderimage: nil, filter: nil, imagetransition: uiimageview.imagetransition.none, completion: { (_, _, imageresult) -> void in             if imageresult.issuccess {                 cell.imagem.image = nil                 cell.imagem.image = imageresult.value?.grayscaleimage()             }         }) 

and class transform image gray scale is:

func grayscaleimage() -> uiimage {     let imagerect = cgrectmake(0, 0, self.size.width, self.size.height);     let colorspace = cgcolorspacecreatedevicegray();      let width = int(self.size.width)     let height = int(self.size.height)     let context = cgbitmapcontextcreate(nil, width, height, 8, 0, colorspace, .allzeros);     cgcontextdrawimage(context, imagerect, self.cgimage!);      let imageref = cgbitmapcontextcreateimage(context);     let newimage = uiimage(cgimage: imageref!)     return newimage }} 


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -