<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
	<channel>
		<title>Reworked HCBP in VB for Better C# conversion.</title>
		<link>https://blogs.lotterypost.com/jadelottery/2012/4/reworked-hcbp-in-vb-for-better-c-conversion.htm</link>
		<atom:link href="https://www.lotterypost.com/rss/blogcomments/64776" rel="self" type="application/rss+xml" />
		<description>JADELottery's Blog: Reworked HCBP in VB for Better C# conversion.</description>
		<dc:language>en-us</dc:language>
		<generator>Lottery Post RSS Generator</generator>
		<item>
			<title>Original Blog Entry: Reworked HCBP in VB for Better C# conversion.</title>
			<link>https://blogs.lotterypost.com/jadelottery/2012/4/reworked-hcbp-in-vb-for-better-c-conversion.htm</link>
			<guid isPermaLink="true">https://blogs.lotterypost.com/jadelottery/2012/4/reworked-hcbp-in-vb-for-better-c-conversion.htm</guid>
			<pubDate>Sun, 01 Apr 2012 14:58:31 GMT</pubDate>
			<dc:creator>JADELottery</dc:creator>
			<description><![CDATA[<p>The problem comes in when converting the VB - Select Case to a C# - Switch Case. We just changed to an If Else.<br /><br />It would be easy to include an Alpha channel and making it an HCBPAtoARGB.<br /><br />If monitors were really setup correctly the RGB would be RGBE, the complement of CMYK.<br /><br />CMYK is Cyan Magenta Yellow blacK<br /><br />RGBE is Red Green Blue whitE<br /><br />__________<br /><br />Function HCBPtoRGB(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double) As Long<br /><br />&#x27;Palette = 0.0 [All Chroma Palette] to Palette = 1.0 [All Saturation Palette]<br /><br />&#x27;Hue, Contrast, Brightness = 0.0 to 1.0 Scale<br /><br />HCBPtoRGB = RGB(Int(255 * HCBPtoR(Hue, Contrast, Brightness, Palette)), Int(255 * HCBPtoG(Hue, Contrast, Brightness, Palette)), Int(255 * HCBPtoB(Hue, Contrast, Brightness, Palette)))<br /><br />End Function<br /><br />Function HCBPtoR(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double)<br /><br />&#x27;Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]<br /><br />Dim r0, g0, b0, h0, c0, m0, x0 As Double &#x27;Chroma Scale<br /><br />Dim r1, g1, b1, h1, c1, m1, x1 As Double &#x27;Saturation Scale<br /><br />c0 = Contrast<br /><br />c1 = (1 - Abs(2 * Brightness - 1)) * Contrast<br /><br />h0 = Hue - Int(Hue)<br /><br />h1 = Hue - Int(Hue)<br /><br />x0 = c0 * (1 - Abs(Modulus((6 * h0), 2) - 1))<br /><br />x1 = c1 * (1 - Abs(Modulus((6 * h1), 2) - 1))<br /><br />If (((0 / 6) = h0) And (h0 (1 / 6))) Then<br /><br />r0 = c0: g0 = x0: b0 = 0<br /><br />ElseIf ((1 / 6) = h0) And (h0 (2 / 6)) Then<br /><br />r0 = x0: g0 = c0: b0 = 0<br /><br />ElseIf ((2 / 6) = h0) And (h0 (3 / 6)) Then<br /><br />r0 = 0: g0 = c0: b0 = x0<br /><br />ElseIf ((3 / 6) = h0) And (h0 (4 / 6)) Then<br /><br />r0 = 0: g0 = x0: b0 = c0<br /><br />ElseIf ((4 / 6) = h0) And (h0 (5 / 6)) Then<br /><br />r0 = x0: g0 = 0: b0 = c0<br /><br />ElseIf ((5 / 6) = h0) And (h0 (6 / 6)) Then<br /><br />r0 = c0: g0 = 0: b0 = x0<br /><br />End If<br /><br />If (((0 / 6) = h1) And (h1 (1 / 6))) Then<br /><br />r1 = c1: g1 = x1: b1 = 0<br /><br />ElseIf ((1 / 6) = h1) And (h1 (2 / 6)) Then<br /><br />r1 = x1: g1 = c1: b1 = 0<br /><br />ElseIf ((2 / 6) = h1) And (h1 (3 / 6)) Then<br /><br />r1 = 0: g1 = c1: b1 = x1<br /><br />ElseIf ((3 / 6) = h1) And (h1 (4 / 6)) Then<br /><br />r1 = 0: g1 = x1: b1 = c1<br /><br />ElseIf ((4 / 6) = h1) And (h1 (5 / 6)) Then<br /><br />r1 = x1: g1 = 0: b1 = c1<br /><br />ElseIf ((5 / 6) = h1) And (h1 (6 / 6)) Then<br /><br />r1 = c1: g1 = 0: b1 = x1<br /><br />End If<br /><br />m0 = Brightness - (0.3 * r0 + 0.59 * g0 + 0.11 * b0)<br /><br />m1 = Brightness - (c1 / 2)<br /><br />If ((1 - Palette) * (r0 + m0) + Palette * (r1 + m1) 1) Then<br /><br />HCBPtoR = 1<br /><br />ElseIf ((1 - Palette) * (r0 + m0) + Palette * (r1 + m1) 0) Then<br /><br />HCBPtoR = 0<br /><br />Else<br /><br />HCBPtoR = (1 - Palette) * (r0 + m0) + Palette * (r1 + m1)<br /><br />End If<br /><br />End Function<br /><br />Function HCBPtoG(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double)<br /><br />&#x27;Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]<br /><br />Dim r0, g0, b0, h0, c0, m0, x0 As Double &#x27;Chroma Scale<br /><br />Dim r1, g1, b1, h1, c1, m1, x1 As Double &#x27;Saturation Scale<br /><br />c0 = Contrast<br /><br />c1 = (1 - Abs(2 * Brightness - 1)) * Contrast<br /><br />h0 = Hue - Int(Hue)<br /><br />h1 = Hue - Int(Hue)<br /><br />x0 = c0 * (1 - Abs(Modulus((6 * h0), 2) - 1))<br /><br />x1 = c1 * (1 - Abs(Modulus((6 * h1), 2) - 1))<br /><br />If (((0 / 6) = h0) And (h0 (1 / 6))) Then<br /><br />r0 = c0: g0 = x0: b0 = 0<br /><br />ElseIf ((1 / 6) = h0) And (h0 (2 / 6)) Then<br /><br />r0 = x0: g0 = c0: b0 = 0<br /><br />ElseIf ((2 / 6) = h0) And (h0 (3 / 6)) Then<br /><br />r0 = 0: g0 = c0: b0 = x0<br /><br />ElseIf ((3 / 6) = h0) And (h0 (4 / 6)) Then<br /><br />r0 = 0: g0 = x0: b0 = c0<br /><br />ElseIf ((4 / 6) = h0) And (h0 (5 / 6)) Then<br /><br />r0 = x0: g0 = 0: b0 = c0<br /><br />ElseIf ((5 / 6) = h0) And (h0 (6 / 6)) Then<br /><br />r0 = c0: g0 = 0: b0 = x0<br /><br />End If<br /><br />If (((0 / 6) = h1) And (h1 (1 / 6))) Then<br /><br />r1 = c1: g1 = x1: b1 = 0<br /><br />ElseIf ((1 / 6) = h1) And (h1 (2 / 6)) Then<br /><br />r1 = x1: g1 = c1: b1 = 0<br /><br />ElseIf ((2 / 6) = h1) And (h1 (3 / 6)) Then<br /><br />r1 = 0: g1 = c1: b1 = x1<br /><br />ElseIf ((3 / 6) = h1) And (h1 (4 / 6)) Then<br /><br />r1 = 0: g1 = x1: b1 = c1<br /><br />ElseIf ((4 / 6) = h1) And (h1 (5 / 6)) Then<br /><br />r1 = x1: g1 = 0: b1 = c1<br /><br />ElseIf ((5 / 6) = h1) And (h1 (6 / 6)) Then<br /><br />r1 = c1: g1 = 0: b1 = x1<br /><br />End If<br /><br />m0 = Brightness - (0.3 * r0 + 0.59 * g0 + 0.11 * b0)<br /><br />m1 = Brightness - (c1 / 2)<br /><br />If ((1 - Palette) * (g0 + m0) + Palette * (g1 + m1) 1) Then<br /><br />HCBPtoG = 1<br /><br />ElseIf ((1 - Palette) * (g0 + m0) + Palette * (g1 + m1) 0) Then<br /><br />HCBPtoG = 0<br /><br />Else<br /><br />HCBPtoG = (1 - Palette) * (g0 + m0) + Palette * (g1 + m1)<br /><br />End If<br /><br />End Function<br /><br />Function HCBPtoB(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double)<br /><br />&#x27;Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]<br /><br />Dim r0, g0, b0, h0, c0, m0, x0 As Double &#x27;Chroma Scale<br /><br />Dim r1, g1, b1, h1, c1, m1, x1 As Double &#x27;Saturation Scale<br /><br />c0 = Contrast<br /><br />c1 = (1 - Abs(2 * Brightness - 1)) * Contrast<br /><br />h0 = Hue - Int(Hue)<br /><br />h1 = Hue - Int(Hue)<br /><br />x0 = c0 * (1 - Abs(Modulus((6 * h0), 2) - 1))<br /><br />x1 = c1 * (1 - Abs(Modulus((6 * h1), 2) - 1))<br /><br />If (((0 / 6) = h0) And (h0 (1 / 6))) Then<br /><br />r0 = c0: g0 = x0: b0 = 0<br /><br />ElseIf ((1 / 6) = h0) And (h0 (2 / 6)) Then<br /><br />r0 = x0: g0 = c0: b0 = 0<br /><br />ElseIf ((2 / 6) = h0) And (h0 (3 / 6)) Then<br /><br />r0 = 0: g0 = c0: b0 = x0<br /><br />ElseIf ((3 / 6) = h0) And (h0 (4 / 6)) Then<br /><br />r0 = 0: g0 = x0: b0 = c0<br /><br />ElseIf ((4 / 6) = h0) And (h0 (5 / 6)) Then<br /><br />r0 = x0: g0 = 0: b0 = c0<br /><br />ElseIf ((5 / 6) = h0) And (h0 (6 / 6)) Then<br /><br />r0 = c0: g0 = 0: b0 = x0<br /><br />End If<br /><br />If (((0 / 6) = h1) And (h1 (1 / 6))) Then<br /><br />r1 = c1: g1 = x1: b1 = 0<br /><br />ElseIf ((1 / 6) = h1) And (h1 (2 / 6)) Then<br /><br />r1 = x1: g1 = c1: b1 = 0<br /><br />ElseIf ((2 / 6) = h1) And (h1 (3 / 6)) Then<br /><br />r1 = 0: g1 = c1: b1 = x1<br /><br />ElseIf ((3 / 6) = h1) And (h1 (4 / 6)) Then<br /><br />r1 = 0: g1 = x1: b1 = c1<br /><br />ElseIf ((4 / 6) = h1) And (h1 (5 / 6)) Then<br /><br />r1 = x1: g1 = 0: b1 = c1<br /><br />ElseIf ((5 / 6) = h1) And (h1 (6 / 6)) Then<br /><br />r1 = c1: g1 = 0: b1 = x1<br /><br />End If<br /><br />m0 = Brightness - (0.3 * r0 + 0.59 * g0 + 0.11 * b0)<br /><br />m1 = Brightness - (c1 / 2)<br /><br />If ((1 - Palette) * (b0 + m0) + Palette * (b1 + m1) 1) Then<br /><br />HCBPtoB = 1<br /><br />ElseIf ((1 - Palette) * (b0 + m0) + Palette * (b1 + m1) 0) Then<br /><br />HCBPtoB = 0<br /><br />Else<br /><br />HCBPtoB = (1 - Palette) * (b0 + m0) + Palette * (b1 + m1)<br /><br />End If<br /><br />End Function<br /><br />Function Modulus(ByVal a As Double, ByVal n As Integer) As Double<br /><br />Modulus = a - (n * Int(a / n))<br /><br />End Function<br /><br />... &#x5b;&#xa0;<a href="https://blogs.lotterypost.com/jadelottery/2012/4/reworked-hcbp-in-vb-for-better-c-conversion.htm">More</a>&#xa0;&#x5d;</p>]]></description>
			<category>Blog Entry</category>
			<category>JADELottery</category>
			<wfw:comment>https://www.lotterypost.com/blogentry/64776</wfw:comment>
		</item>
	</channel>
</rss>

