Image Reflection

Discussion in 'Mac Programming' started by Spike099, Jun 26, 2007.

  1. macrumors regular

    Joined:
    Feb 18, 2007
    Location:
    Canada
    #1
    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.
     
  2. ATG
    macrumors regular

    Joined:
    Aug 7, 2005
    #2
    http://www.kaintek.com/?page_id=40

    I haven't used it, but a google goes a long way ;)
     
  3. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    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
     
  4. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Aw shucks :eek: :)

    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.
     
  5. ATG
    macrumors regular

    Joined:
    Aug 7, 2005
    #5
    Why not just draw the normal view into an image and then reflect that?
     
  6. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    If I'd know it was you... :eek:

    What doesn't work with transparent images? Do the colours shift?
     
  7. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #7
    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.
     
  8. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    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...
     
  9. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #9
    This guy's code handles transparency and is much smaller and more efficient than mine.
     
  10. thread starter macrumors regular

    Joined:
    Feb 18, 2007
    Location:
    Canada
    #10
    Thank you

    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.
     

Share This Page