You know what would be über cool? Getting Core Image Filters, including filters, to work.
Guess this is a awful lot of declares and a but out of my league.
You know what would be über cool? Getting Core Image Filters, including filters, to work.
Guess this is a awful lot of declares and a but out of my league.
[quote=158613:@Christoph De Vocht]You know what would be über cool? Getting Core Image Filters, including filters, to work.
Guess this is a awful lot of declares and a but out of my league.[/quote]
Sam Rowlands is probably the man to talk to, but from what he has shared about Core Image in the forum, that is extremely far from simple.
Yes, this would not be easy. But I think many would gladly pay for such feature (I would).
We’ll see what we can do over time.
Shouldn’t be too difficult. An IOSImage is a UIImage and has a CIImage property. CIFilters are simple to create with CIFilter’s filterWithName, then configure with setValueForKey. Then create a UIImage from the outputImage with imageWithCIImage. Back to IOSImage with IOSImage.fromHandle
The only time consuming thing would be if you want to create classes for each available filter with all of the parameters etc…
Here’s something you might like (you’ll want to refere to the CIFilter docs…
Usage looks like this (“im” is an IOSBitmap)
[code] dim f As new CIFilter(“CIGaussianBlur”)
f.parameter(“inputRadius”)=Slider1.Value
f.inputImage=im.Image
dim f2 as new CIFilter(“CIHoleDistortion”)
f2.parameter(“inputCenter”)="[20 100]"
f2.parameter(“inputRadius”)=20
f2.inputImageFromCIFilter=f.outputImageForCIFilter
g.DrawImage(f2.outputImage,0,0)[/code]
There’s also a shared method to get a list of available filters.
Some Filters will return an image larger than the original, or with infinite dimensions and will need a CICrop applied (the CICrop’s inputRectangle vector can be set like “[0 0 100 100]”).
Filter away!
[quote=158646:@jim mckay]Here’s something you might like (you’ll want to refere to the CIFilter docs…
Usage looks like this (“im” is an IOSBitmap)
[code] dim f As new CIFilter(“CIGaussianBlur”)
f.parameter(“inputRadius”)=Slider1.Value
f.inputImage=im.Image
dim f2 as new CIFilter(“CIHoleDistortion”)
f2.parameter(“inputCenter”)="[20 100]"
f2.parameter(“inputRadius”)=20
f2.inputImageFromCIFilter=f.outputImageForCIFilter
g.DrawImage(f2.outputImage,0,0)[/code]
There’s also a shared method to get a list of available filters.
Some Filters will return an image larger than the original, or with infinite dimensions and will need a CICrop applied (the CICrop’s inputRectangle vector can be set like “[0 0 100 100]”).
Filter away![/quote]
Splendid ! Thank you Jim
@Jim:
Great Job and yes, some filter do make the image bigger (Bloom, CIFilterLanczosScaleTransform, …)
In Swift you do not have to use the Crop filter but the class imageByCroppingToRect
So it would be something like this:
dim rec as new CGRect
rec.Width = im.Image.Width
rec.Height = im.Image.Height
g.DrawImage(f2.outputImage. imageByCroppingToRect(rec),0,0)
So if you could add imageByCroppingToRect, that would resolve this too.
This is what we need:
SWIFT
func imageByCroppingToRect(_ r: CGRect) -> CIImage!
OBJECTIVE-C
Can this be added?
Done! Same download link as before.
I decided to add CGRect as a private struct to the class, to avoid naming conflicts with other classes/modules. This also saves having to declare a CGRect every time…
it would be used like
f2.outputImageByCroppingToRect(x,y,width,height)
Awesome Jim. Works perfect.
This enables us to make great image editing apps. If we only could get access to the photo library - that seems not possible.
It is possible
To save an image to the photo library:
https://forum.xojo.com/18570-save-image/p1#p156706
To access the photo library:
https://forum.xojo.com/18018-barcode-scanning-ios/p1#p152282
Did anyone of you manage to read the extent value of a CIImage? I know it’s not needed for iOS but on the OS X side there’s no imageWithCIImage method for NSImages so I need to take the route via CGImage. Every time I try to address the property via
[quote]#elseif target32bit
dim result as NSRect32Bit
Declare function extent lib appkit selector “extent” (id as ptr) as NSRect32Bit
result = extent (id)
return result.NSRect64
#endif[/quote]
the project crashes with a Kern Invalid address error. NSRect and CGRect are the same, if I read correctly
or aren’t they?
@Jean-Paul: Not in a simple project but an expanding lib. I have this on a private GitHub repository because I use the current beta for it. If you like and send me your GitHub handle, I can invite you to it.
Ok it’s not that extent isn’t working, it is that outputImage returns NIL although it is almost completely like Jim’s method, only for Mac OS X. And that while the filters are working Sorry for hijacking this thread, I’ll post a question to the OS X forum.
ulrich can you invite me too please?
I am restructuring the code, therefore it will change in many places, but I will try to keep the functionality attained so far workable during that time. Therefore I don’t want to put the repository on public access yet but if you are interested, just send me your Github name.
Oh, wonderful project Jim and very helpful for me, but when I try to use “outputImageByCroppingToRect” it works on the iOS Simulator and not in the real device (iPad Air). Anyone have an idea why this is happening?
I took a look and it needed a couple #if target64bit lines and a 64bit CGRect structure added.
Try downloading again and check that it works now.