BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.25k stars 4.61k forks source link

Color Fill / Gradient Fill #274

Open michaelloistl opened 12 years ago

michaelloistl commented 12 years ago

Hi,

I have various situations where I would need to apply color/gradient fills together with blend modes (including a hue blend mode) and opacity. I do this currently via UIGraphicsBeginImageContext ... and draw the color fill into the context by applying a blend mode and opacity. However beside the fact that it would probably be more efficient to have it as part of a GPUImageFilterGroup, I face the problem that my source images have transparent parts. When applying the color/gradient fill via my current method, the transparent areas get rendered as well and depending on the filter they are slightly to fully visible.

What would you suggest in order to keep transparent areas fully transparent but still applying color/gradient fills ?

Hope my description is clear enough.

Many thanks, Michael

BradLarson commented 12 years ago

Are you asking how to overlay an image with transparency on a solid color or a gradient?

If you have the solid color or gradient as an image (perhaps input as a UIImage after you've drawn it via Core Graphics), you should be able to use a GPUImageAlphaBlendFilter with that as the first input and the image with transparency as the second.

Would it help if there was a filter to generate the solid color or gradient within the framework? I've thought about adding a little color generator or two-color gradient filter, like Core Image has, and it wouldn't take that much work to do.

michaelloistl commented 12 years ago

Thanks for the quick reply.

My color fill / gradient fill images have already transparency applied. However it would be really helpful if your framework would offer filter to generate the solid color or gradient within the framework.

My biggest problem right now is that the filter chain includes these full size color / gradient fills and that all other filters apply to them as well and not just to the non transparent area of the original image.

Hope it's clear what I mean. If not, I can send you a sample image, showing the problem.

We also miss hue blendmode as well as hue adjust filter within your framework. We do these also via UIGraphicsBeginImageContext... as well as CIHueAdjust CIFilter. Do you have any plans to add them to your framework ?

Should probably another issue, but I just quickly mention it here: Our designer would require filter like "selective color" and "color balance" as available in photoshop. I haven't found any filters in your framework nor in the CIFilter reference that would allow me to setup such filters. Any hint from your side ?

iamcam commented 12 years ago

I second the need for a hue filter. It would simplify the Photoshop -> GPUImage conversion process. I'll post a new ticket.

iamcam commented 12 years ago

Posted: https://github.com/BradLarson/GPUImage/issues/276

michaelloistl commented 12 years ago

Just following up on the filter to generate the solid color or gradient within the framework. Has this filter already been added to the framework ?

iamcam commented 12 years ago

@michaelloistl Not yet. You might be able to make the solid fill filter pretty easily. Let us know if you do.

michaelloistl commented 12 years ago

I do this currently via UIGraphicsBeginImageContext ... and draw the color fill into the context by applying a blend mode and opacity. I just thought that it would be more efficient to have this as filter within your framework so that this action can happen within the filter group. Would be more efficient ...

BradLarson commented 12 years ago

The first part of this has now been implemented in the GPUImageSolidColorGenerator, which will generate an image containing just a solid color. I'm still working on the gradients.

haihw commented 12 years ago

Hi Brad, I am trying generate Gradient by using CGContextDrawRadialGradient and CGContextDrawLinearGradient But I think that solution effect the performance of other filter in the chain. And the result gradient is also not good. When I add radial gradient from white full alpha color (1,1,1,1) to zero alpha one(1,1,1,0), It make background image darker instead of whiter as in Photoshop or Gimp. http://farm9.staticflickr.com/8302/7975461327_814c0696c8_z.jpg

Hope Gradient generator release soon.