15,569,547 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Mike-MadBadger (Top 15 by date)
Mike-MadBadger
22-Oct-13 17:02pm
View
I think it may help if you assume I'm a rank amateur.
(I wonder if there is some confusion? I am looking at a library rather than an application, does that make a difference?)
Do you mean that it (and it would be only one) would work with a hidden color space, say CIE 1931 XYZ since it is the common reference, and that to obtain a model or a space, whichever is desired, this object would have methods that kick out a new object of the desired type? Presumably it could then construct itself on the basis of being given any color object, model or space - the reverse to the previous sentence and that perhaps the constructor could have an optional parameter of space, the default of which exposes the default space which is not directly accessible otherwise? How would you assign colors the model that it contains without specifying a model type and exposing its members, Red, Green and Blue for example?
Mike-MadBadger
22-Oct-13 16:25pm
View
Let's see if I've understood:
The classes, as conceived, don't think at all about actual drawing, they are just objects to manage colors, either color models or color spaces plus the conversions and the transitions between spaces and models (which is often confused). A color space being the manner in which a model becomes something real rather than abstract.
However, I think you are suggesting this:
A class called Color which contains as a member an interface, let's call it IColorModel.
The classes that manage the color models must implement IColorModel, RGB, CMYK etc.
The Color class should have a second member called IColorSpace which allows the model to be interpreted in such a way that it can be rendered correctly.
Color model conversions, e.g. RGB to CMYK, simply change the IColorModel member.
Color space changes, e.g. CIE 1931 XYZ to Adobe RGB change the IColorSpace member and have consequent changes on the IColorModel member, either a complete change or a change in the detail: CIELAB to sRGB would change both, Adobe RGB to sRGB would change the space and the detail of the model.
The ToGray methods, as an example, would call the relavant method of the IColor member which would probably also implement the IColorToGrey interface, both interface members pointing at the same actual object.
Have I understood anything?
Mike-MadBadger
20-Oct-13 16:48pm
View
aCMYK newColor = new aCMYK();
newColor.ToGrey(GreyScaleMethod.RedChannel)
Public Interface IToGrey
Sub ToGrey(ByRef color As IColorModelConvertible)
End Interface
Public Interface IColorModelConvertible
Function ToARGB(Optional ByVal alpha As Integer = 255) As aRGB
Function ToColor(Optional ByVal alpha As Integer = 255) As Color
Function ToAHSB() As aHSB
Function ToAHSL() As aHSL
Function ToACMYK() As aCMYK
Function ToHex(Optional ByVal alpha As Integer = 255) As String
End Interface
Public Class RGBAverage
Implements IToGrey
Public Sub ToGrey(ByRef color As IColorModelConvertible) Implements IToGrey.ToGrey
Dim newARGB As aRGB = color.ToARGB()
newRGB.Green = newRGB.Red()
newRGB.Blue = newRGB.Red()
color = newRGB.To [Help: Don't know original class type!)
End Sub
Mike-MadBadger
27-Aug-13 16:27pm
View
Out of interest (sorry for the delay) why custom rather than InvalidEnumArgumentException or ArgumentOutOfRangeException?
I get the idea / benefit of writing your own exceptions, however those two seem pretty well aligned with the problem at hand?
Mike-MadBadger
27-Aug-13 16:23pm
View
Struggled a bit to understand your articles, they are, at least as yet, a bit ahead of me - hopefully I'll get there sooner or later.
I did however find this: http://blogs.microsoft.co.il/blogs/gilf/archive/2009/11/22/applying-strategy-pattern-instead-of-using-switch-statements.aspx
I found it be a usefully simpler explanation for my level.
Mike-MadBadger
25-Aug-13 13:16pm
View
Thanks, I've started doing a thorough examination of how it works in a variety of circumstances.
My question here was linked to the one linked below and the implementation of a
Switch...Case...Default
http://www.codeproject.com/Questions/639070/Exceptions-for-Enum-Method-Parameters
Mike-MadBadger
19-Aug-13 2:29am
View
Thanks, I will keep this for futur e reference. In this case however it feels a bit like overkill since the chances of me inventing a significantly increased number of ways of converting colour to greyscale are limited (and hence changing the enumeration).
The switch remains ugly but 'more readable' (to me) than adding the code from your two articles.
Mike-MadBadger
19-Aug-13 2:26am
View
Thanks, useful and straightforward. I guess I was wondering if the compiler added the relevant code to handle problems gracefully and informatively if, for example, someone passed in a typecast integer that was out of range. Or if it would throw a largely useless and informative error. The latter case, in my original thinking, would be the only justification for adding my own error..throw code, however...
You're second point is the same as that of RLH68? (his comment on my question). I'd forgotten to think of the error from both directions in either case.
For interest, which error type do you throw?
Mike-MadBadger
14-Apr-13 9:15am
View
Can you show the code you have found and which you can't follow
Mike-MadBadger
14-Apr-13 9:11am
View
There are lots of sources out there, as you have said.
Do you mean you don't understand the code they use?
Or that you don't fully understand the language used (presuming English isn't your first language)?
The obvious approach of taking each letter of the string and working away from it in both directions appears to be the least efficient (but it should be simple to code). Do you need to find 'better' answers?
Mike-MadBadger
24-Mar-13 3:18am
View
You will need tom specify the question a bit more.
Do you mean how do you use the OpenFileDialog componenrt to open images?
Do you mean you want to set an image preoperty for a control (such as a PictureBox)
Or something else?
Mike-MadBadger
15-Mar-13 3:25am
View
See the following answer.
Mike-MadBadger
24-Nov-12 6:12am
View
You could argue that C# is hiding the behaviour that MSDN describes and that VB reveals in indirectly by doing 'weird' stuff. A win for VB.
Or you could say that C# is saying 'don't worry about what crazy stuff the compiler is going to do, I'll make you be sufficiently clear that it doesn't matter'.
A Win for C#. In some weird way the behaviour MS have chosen makes sense to me (maybe it goes back to having learnt procedural coding on a BBC Model B). Choice your posion and off you go, whatever you decide someone is gonna say 'brilliant' and right after someone else will say 'idiot'.
Mike-MadBadger
24-Nov-12 6:11am
View
Deleted
You could argue that C# is hiding the behaviour that MSDN describes and that VB reveals in indirectly by doing 'weird' stuff. A win for VB.
Or you could say that C# is saying 'don't worry about what crazy stuff the compiler is going to do, I'll make you be sufficiently clear that it doesn't matter'. A Win for C#.
In some weird way the behaviour MS have chosen makes sense to me (maybe it goes back to having learnt procedural coding on a BBC Model B).
Choice your posion and off you go, whatever you decide someone is gonna say 'brilliant' and right after someone else will say 'idiot'.
Mike-MadBadger
22-Oct-12 4:19am
View
What was your expectation?
Show More