• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CGShading
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGShading


  • Subject: Re: CGShading
  • From: Ricky Sharp <email@hidden>
  • Date: Sun, 1 Aug 2004 09:13:00 -0500

On Jul 31, 2004, at 5:40 PM, Peter Laurens wrote:

I am attempting to draw a simple gradient shade, and I have been slowly going through the Quartz documentation to try and learn how to achieve this.

I was pleased to see a sample project that shows off some code how to do this. Unfortunately it's a very complex set of code with all sorts of bits scattered all over the place in strange different functions, and so it's difficult for me to follow properly... impossible in fact. I am having a hard time stripping out the core stuff I need for a gradient to be drawn, and the extra fluff the developer has added around it.

Does anyone have a real simple CGShading demo project for me to take a look at?

I'd be incredibly grateful for any help at all,

I have yet no idea how the following would compare speed-wise (I do plan to profile them over the next week as I too need a gradient solution):

(1) For very simple linear gradients, what I used to do in Carbon was to create a GWorld. Say I wanted a linear gradient going from top to bottom for a 200 x 200 pixel area. The GWorld would be 1 pixel wide and 200 pixels tall. Then, for all 200 pixels, I would directly draw into the GWorld (Direct Pixel Access) the appropriate colored point. Finally, I would use CopyBits with dither mode to draw the GWorld into the 200 x 200 area. You'd get a nice dithered gradient at any bit-depth. A similar solution should definitely existing if working with NSImage

(2) Draw directly into an NSImage. Here's some sample code that creates a pretty cool gradient by using a Category for NSImage:

<http://developer.apple.com/samplecode/Transformed_Image/ Transformed_Image.html>

(3) Use CGShading.

(4) Believe it or not, it appears you can use QuickTime. I found this in some older (1999) documentation:

<http://developer.apple.com/documentation/QuickTime/REF/ refVectors.39.htm#pgfId=34866>


___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: CGShading
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Find panel
  • Next by Date: Re: Password encryption
  • Previous by thread: Re: Find panel
  • Next by thread: Re: CGShading
  • Index(es):
    • Date
    • Thread