Bug 151 - CoreGraphics Context color-setting API needs work
Summary: CoreGraphics Context color-setting API needs work
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-08-02 17:49 UTC by Jeffrey Stedfast
Modified: 2011-10-06 14:53 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jeffrey Stedfast 2011-08-02 17:49:05 UTC
As I was debugging https://bugzilla.novell.com/show_bug.cgi?id=656843 I found a couple of issues with the current CGContext.Set[Stroke,Fill]Color() API.

First of all, it should be documented in BOLD PRINT that you MUST set the ColorSpace first. Secondly, we really need to do some validation of the float[] array to make sure it is of an appropriate length for the current ColorSpace...

which brings up a problem: how do you get the current ColorSpace? There doesn't appear to be an API for that.

I propose we mark this API as OBSOLETE since even Apple is suggesting in their docs that you use SetColorWithColor.
Comment 1 Jeffrey Stedfast 2011-08-02 18:38:03 UTC
Currently setting the color for stroke & fill is as follows:


SetCMYKStrokeColor (float, float, float, float, float);
SetRGBStrokeColor (float, float, float, float);
SetGrayStrokeColor (float, float);
SetStrokeColorWithColor (CGColor);
SetStrokeColor (float[]);

I propose we [Obsolete] all of the above methods (except maybe the last one) and add:

SetStrokeColor (float cyan, float magenta, float yellow, float black, float alpha);
SetStrokeColor (float red, float green, float blue, float alpha);
SetStrokeColor (float gray, float alpha);
SetStrokeColor (CGColor color);

I think this will make the API a bit cleaner.


I've already taken care of the API documentation for the current float[] API for both Stroke and Fill color-setting.

Still unknown: How to do array validation?
Comment 2 Jeffrey Stedfast 2011-08-02 19:31:09 UTC
I've implemented this:

SetStrokeColor (float cyan, float magenta, float yellow, float black, float alpha);
SetStrokeColor (float red, float green, float blue, float alpha);
SetStrokeColor (float gray, float alpha);
SetStrokeColor (CGColor color);

in maccore trunk.
Comment 3 Jeffrey Stedfast 2011-10-06 14:53:11 UTC
Going to mark as fixed