PDA

View Full Version : Image Reflection




Spike099
Jun 26, 2007, 04:27 PM
Alright, I apologize if this has been asked already however I cannot find anything about it. I am looking to create the image reflection effect that is seen in many os x apps like frontrow, iweb, keynote and many others.

Do I have to create a filter using CIImage? Or is this done using CGImage or even an NSImage? Any pointers are appreciated, thanks.



ATG
Jun 26, 2007, 05:05 PM
Alright, I apologize if this has been asked already however I cannot find anything about it. I am looking to create the image reflection effect that is seen in many os x apps like frontrow, iweb, keynote and many others.

Do I have to create a filter using CIImage? Or is this done using CGImage or even an NSImage? Any pointers are appreciated, thanks.
http://www.kaintek.com/?page_id=40

I haven't used it, but a google goes a long way ;)

robbieduncan
Jun 26, 2007, 05:07 PM
There is no single line of code to do this. There are numerous examples of how to do it if you Google.

For example this one (http://www.kaintek.com/?page_id=40)

kainjow
Jun 26, 2007, 07:00 PM
http://www.kaintek.com/?page_id=40

For example this one (http://www.kaintek.com/?page_id=40)

Aw shucks :o :)

I just updated the Subversion URL for the code, so it is actually downloadable (via 'svn co ...'). It isn't the best code for doing this, and doesn't work well with transparent images.

What would be best is to make a view that draws another view as a reflection. I haven't yet figured out how to do that though.

ATG
Jun 27, 2007, 03:25 AM
Aw shucks :o :)

I just updated the Subversion URL for the code, so it is actually downloadable (via 'svn co ...'). It isn't the best code for doing this, and doesn't work well with transparent images.

What would be best is to make a view that draws another view as a reflection. I haven't yet figured out how to do that though.
Why not just draw the normal view into an image and then reflect that?

robbieduncan
Jun 27, 2007, 03:32 AM
Aw shucks :o :)

I just updated the Subversion URL for the code, so it is actually downloadable (via 'svn co ...'). It isn't the best code for doing this, and doesn't work well with transparent images.

If I'd know it was you... :eek:

What doesn't work with transparent images? Do the colours shift?

kainjow
Jun 27, 2007, 06:55 AM
What doesn't work with transparent images? Do the colours shift?

When I draw the reflected image, I draw a gradient over the image that fades to the background color, so wherever there's transparency, it draws over that, instead of ignoring it. I need to find a way of clipping the drawing using the image's mask.

robbieduncan
Jun 27, 2007, 07:31 AM
When I draw the reflected image, I draw a gradient over the image that fades to the background color, so wherever there's transparency, it draws over that, instead of ignoring it. I need to find a way of clipping the drawing using the image's mask.

Ah. I didn't look at the code but I assumed you'd used the gradient as an alpha mask. I was expecting to here tails of wow around pre-multiplied alpha images...

kainjow
Jun 27, 2007, 07:59 AM
This (http://bithaus.com/2006/11/05/nsimage-reflection/) guy's code handles transparency and is much smaller and more efficient than mine.

Spike099
Jun 27, 2007, 07:21 PM
Thanks for the feedback guys. I haven't tried these samples yet as I ran into another noobish problem thats preventing me from trying. I'll post the problem in a new thread.