1

In order to write a flood-fill method of mine in Swift, I am trying as a first step to compile the code I found here: iOS Swift Flood fill algorithm So that I can see how it works. But I get errors.

The first one being: Value of type 'UIImage' has no member 'createARGBBitmapContext' Since I have no experience with extensions I may well be doing something wrong.

Any suggestions?

Community
  • 1
  • 1
Michel
  • 10,303
  • 17
  • 82
  • 179
  • `createARGBBitmapContext()` is apparently a local function in the http://stackoverflow.com/questions/30580688/ios-swift-flood-fill-algorithm project, but the definition is not shown. Why don't you leave a comment at that question and ask for clarification? – Martin R Oct 24 '15 at 08:22
  • 1
    It comes from [Apple Q&A 1509](https://developer.apple.com/library/mac/qa/qa1509/_index.html) which the author of that question obviously ported to Swift. See http://stackoverflow.com/questions/26685598/creating-uiimage-from-nsdata-created-from-buffer-returns-nil/26686111#26686111 or http://stackoverflow.com/questions/31661023/change-color-of-certain-pixels-in-a-uiimage/31661519#31661519 for examples of manipulating pixel buffer in Swift. – Rob Oct 24 '15 at 08:22
  • I have already left a comment on the question as Martin suggests. Thanks for the couple of links, in Rob's comment, I hope that will allow me to make a few more steps. – Michel Oct 24 '15 at 08:29
  • This http://stackoverflow.com/questions/31661023/change-color-of-certain-pixels-in-a-uiimage/31661519#31661519 suggested above is helpful. But how do I set the resulting image? My code is: UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0) view.layer.renderInContext(UIGraphicsGetCurrentContext()!) let originalImage:UIImage = UIGraphicsGetImageFromCurrentImageContext() let newImage = processPixelsInImage(originalImage:UIImage) let imageView:UIImageView = UIImageView.init(image: newImage) self.view.addSubview(imageView) I feel the last 2 instructions are not right. – Michel Oct 24 '15 at 16:18

0 Answers0