FROM : R. Scott Thompson
DATE : Tue Oct 12 21:30:13 2004
>>>> 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>
>>>>
>>
>> When I wrote that code, CGShading wasn't available. If I were
>> writing that sample today, I'd use GCShading. I should also point
>> out that the code assumes that bytesPerRow == pixelsWide, which isn't
>> necessarily the case.
>
> Correction: I meant to say it assumes that bytesPerRow ==
> (pixelsWide * 4), which isn't necessarily true. In future versions
> of AppKit and CoreImage, bitmaps may get padded to allow for word or
> long word alignment for optimization.
Just a note, I don't think that CGShading will let you create the same
kind of gradient in the sample (at least not easily). The gradient in
the sample looks to be a smooth blend between four different colors at
the four corners of the rectangle. CGShading, in contrast, will let
you create linear (axial) or circular (radial) shadings, but not
arbitrary barycentric blends as is shown in the sample.
The easiest way I can think of to create something like that on Mac OS
X would be to use OpenGL.
--
Macintosh Software Engineering Consulting Services
Visit my resume at <http://homepage.mac.com/easco/RSTResume.html>
DATE : Tue Oct 12 21:30:13 2004
>>>> 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>
>>>>
>>
>> When I wrote that code, CGShading wasn't available. If I were
>> writing that sample today, I'd use GCShading. I should also point
>> out that the code assumes that bytesPerRow == pixelsWide, which isn't
>> necessarily the case.
>
> Correction: I meant to say it assumes that bytesPerRow ==
> (pixelsWide * 4), which isn't necessarily true. In future versions
> of AppKit and CoreImage, bitmaps may get padded to allow for word or
> long word alignment for optimization.
Just a note, I don't think that CGShading will let you create the same
kind of gradient in the sample (at least not easily). The gradient in
the sample looks to be a smooth blend between four different colors at
the four corners of the rectangle. CGShading, in contrast, will let
you create linear (axial) or circular (radial) shadings, but not
arbitrary barycentric blends as is shown in the sample.
The easiest way I can think of to create something like that on Mac OS
X would be to use OpenGL.
--
Macintosh Software Engineering Consulting Services
Visit my resume at <http://homepage.mac.com/easco/RSTResume.html>
| Related mails | Author | Date |
|---|---|---|
| Peter Laurens | Aug 1, 00:40 | |
| Shawn Erickson | Aug 1, 00:53 | |
| Shawn Erickson | Aug 1, 00:59 | |
| Shawn Erickson | Aug 1, 01:09 | |
| Scott Thompson | Aug 1, 03:35 | |
| Perry Clarke | Aug 1, 05:16 | |
| Ricky Sharp | Aug 1, 16:13 | |
| Ricky Sharp | Aug 1, 18:27 | |
| John C. Randolph | Oct 12, 20:38 | |
| John C. Randolph | Oct 12, 20:48 | |
| R. Scott Thompson | Oct 12, 21:30 | |
| John C. Randolph | Oct 12, 22:29 | |
| R. Scott Thompson | Oct 12, 22:41 | |
| John C. Randolph | Oct 12, 23:07 | |
| R. Scott Thompson | Oct 12, 23:31 | |
| John C. Randolph | Oct 13, 01:38 | |
| R. Scott Thompson | Oct 13, 03:41 | |
| John C. Randolph | Oct 14, 00:26 |






Cocoa mail archive

