<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Farbe herausbekommen am Farbspektrum?]]></title><description><![CDATA[<p>Hallo.<br />
Ich habe im Internet einen Snippet gefunden (weiß leider nicht mehr woher), womit man relativ gut aussehende Farbspektren anzeigen kann. Ich habe es mal auf meinen Grafikwrapper angepasst.</p>
<p>Hier ist der Code:</p>
<pre><code class="language-cpp">void CColors::drawSpektrum(int iX, int iY)
{
	int iAlpha = pDraw-&gt;getAlpha();

	for (int i = 0; i &lt;= 255; i += 6)
	{
		if (i % 6 == 0) // edit: mir fällt gerade auf wie sinnlos diese Zeile ist...
		{
			pDraw-&gt;setAlpha(255);
			pDraw-&gt;stripe(iX + (i / 6), iY, 510, true, 255, i, 0);
			pDraw-&gt;stripe(iX + 129 + (i / 6), iY, 510, true, 0, 255 - i, 255);
			pDraw-&gt;stripe(iX + 43 + (i / 6), iY, 510, true, 255 - i, 255, 0);
			pDraw-&gt;stripe(iX + 172 + (i / 6), iY, 510, true, i, 0, 255);
			pDraw-&gt;stripe(iX + 86 + (i / 6), iY, 510, true, 0, 255, i);
			pDraw-&gt;stripe(iX + 215 + (i / 6), iY, 510, true, 255, 0, 255 - i);
		}
	}

	for (int i = 0; i &lt;= 255; i++)
	{
		pDraw-&gt;setAlpha(255 - i);
		pDraw-&gt;stripe(iX, iY + i, 258, false, 255, 255, 255);
		pDraw-&gt;setAlpha(i);
		pDraw-&gt;stripe(iX, iY + 255 + i, 258, false, 0, 0, 0);
	}

	pDraw-&gt;setAlpha(iAlpha);
}

// Prototype von CDraw::stripe:
void stripe(int iX, int iY, int iLength, bool bVertical, int iR, int iG, int iB);
</code></pre>
<p>Wenn ich nun mit der Maus irgendwo darein klicke, würde ich gerne die Farbe herausbekommen. Das Problem: Ich weiß nicht wie man das anstellen kann. Ich hatte an <code>GetPixel</code> gedacht, aber das ist doof, da<br />
a) unsauber da Workaround<br />
b) langsam (spielt hier zwar keine Rolle aber trotzdem)<br />
c) bei Überdeckung des Spektrums durch ein anderes Fenster die Farbe nicht mehr stimmt</p>
<p>Hier ist mal ein Bild des ganzen wie es dann bei mir aussieht: <a href="http://www.abload.de/img/spektrumz6nx.png" rel="nofollow">http://www.abload.de/img/spektrumz6nx.png</a></p>
<p>Bin dankbar für Ratschläge <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/265918/farbe-herausbekommen-am-farbspektrum</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 15:44:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/265918.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Apr 2010 22:48:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Fri, 30 Apr 2010 22:52:00 GMT]]></title><description><![CDATA[<p>Hallo.<br />
Ich habe im Internet einen Snippet gefunden (weiß leider nicht mehr woher), womit man relativ gut aussehende Farbspektren anzeigen kann. Ich habe es mal auf meinen Grafikwrapper angepasst.</p>
<p>Hier ist der Code:</p>
<pre><code class="language-cpp">void CColors::drawSpektrum(int iX, int iY)
{
	int iAlpha = pDraw-&gt;getAlpha();

	for (int i = 0; i &lt;= 255; i += 6)
	{
		if (i % 6 == 0) // edit: mir fällt gerade auf wie sinnlos diese Zeile ist...
		{
			pDraw-&gt;setAlpha(255);
			pDraw-&gt;stripe(iX + (i / 6), iY, 510, true, 255, i, 0);
			pDraw-&gt;stripe(iX + 129 + (i / 6), iY, 510, true, 0, 255 - i, 255);
			pDraw-&gt;stripe(iX + 43 + (i / 6), iY, 510, true, 255 - i, 255, 0);
			pDraw-&gt;stripe(iX + 172 + (i / 6), iY, 510, true, i, 0, 255);
			pDraw-&gt;stripe(iX + 86 + (i / 6), iY, 510, true, 0, 255, i);
			pDraw-&gt;stripe(iX + 215 + (i / 6), iY, 510, true, 255, 0, 255 - i);
		}
	}

	for (int i = 0; i &lt;= 255; i++)
	{
		pDraw-&gt;setAlpha(255 - i);
		pDraw-&gt;stripe(iX, iY + i, 258, false, 255, 255, 255);
		pDraw-&gt;setAlpha(i);
		pDraw-&gt;stripe(iX, iY + 255 + i, 258, false, 0, 0, 0);
	}

	pDraw-&gt;setAlpha(iAlpha);
}

// Prototype von CDraw::stripe:
void stripe(int iX, int iY, int iLength, bool bVertical, int iR, int iG, int iB);
</code></pre>
<p>Wenn ich nun mit der Maus irgendwo darein klicke, würde ich gerne die Farbe herausbekommen. Das Problem: Ich weiß nicht wie man das anstellen kann. Ich hatte an <code>GetPixel</code> gedacht, aber das ist doof, da<br />
a) unsauber da Workaround<br />
b) langsam (spielt hier zwar keine Rolle aber trotzdem)<br />
c) bei Überdeckung des Spektrums durch ein anderes Fenster die Farbe nicht mehr stimmt</p>
<p>Hier ist mal ein Bild des ganzen wie es dann bei mir aussieht: <a href="http://www.abload.de/img/spektrumz6nx.png" rel="nofollow">http://www.abload.de/img/spektrumz6nx.png</a></p>
<p>Bin dankbar für Ratschläge <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890722</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Fri, 30 Apr 2010 22:52:00 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 04:00:20 GMT]]></title><description><![CDATA[<p>theliquidwave schrieb:</p>
<blockquote>
<p>Hallo.<br />
Ich habe im Internet einen Snippet gefunden<br />
...<br />
Wenn ich nun mit der Maus irgendwo darein klicke, würde ich gerne die Farbe herausbekommen.</p>
</blockquote>
<p>Eigentlich total einfach sowas hin zu bekommen, wenn man nur ein bisschen was verstehen würde, was man so macht und nicht alles aus dem Internet klaut.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890740</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890740</guid><dc:creator><![CDATA[Codemonkey]]></dc:creator><pubDate>Sat, 01 May 2010 04:00:20 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 10:28:41 GMT]]></title><description><![CDATA[<p>Hi...<br />
1. Habe ich versucht das Ding zu verstehen und das habe ich auch geschafft.<br />
2. Das größte Problem für mich ist aber nun, dass das Spektrum auch mit Transparenz arbeitet, um die Helligkeit auch einstellen zu können.</p>
<p>Wenn ich beispielsweise weiß, dass der Cursor weiter unten links steht, kann ich ja problemlos raus kriegen, dass dort rot ist. Das schwarze wird ja nur mit einer Transparenz darüber gemalt. Wie kriege ich nun raus, was Rot <code>(255, 0, 0, 255)</code> und Schwarz mit einer Transparenz von 150 <code>(0, 0, 0, 150)</code> für einen Farbwert ergeben?</p>
<p>Vielleicht habe ich das etwas komisch beschrieben oben. Aber ich meinte damit eher das Zusammenmischen der Farben...</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890818</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Sat, 01 May 2010 10:28:41 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 10:29:55 GMT]]></title><description><![CDATA[<p>Anhand der x,y Position deiner Maus würde ich mal sagen, kannst du dann die Farbe errechnen lassen. Sollte eigentlich gar nicht so schwer sein, wie mein Vorgänger das schon gesagt hat, aber halt etwas schorf... Man musses versuchen zu Verstehen. Und da du wahrscheinlich jmd. eine Farbe auswählen lassen Willst, einfach bisschen was in eine neue Funktion basteln o.ä. und dann da die X, Y der Maus übergeben und ausrechnen, fertig ist der lack, ganz simpel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890820</guid><dc:creator><![CDATA[Blackskyliner]]></dc:creator><pubDate>Sat, 01 May 2010 10:29:55 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 10:40:09 GMT]]></title><description><![CDATA[<p>Ja, das ist mir schon klar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Ich versuche noch mal das genauer zu erklären:</p>
<p>Es scheitert eigentlich gar nicht am Code, sondern eher daran, zu verstehen, wie die Farbe Rot (255, 0, 0, 255) mit Schwarz (0, 0, 0, 150) oder mit Weiß (255, 255, 255, 100) aussehen könnte (also welcher Farbwert letztendlich rauskommt). Vielleicht ist das ganze auch einfach. Aber meine letzte Kunststunde liegt schon etwas länger zurück...</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890825</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Sat, 01 May 2010 10:40:09 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 10:49:33 GMT]]></title><description><![CDATA[<p>Gehen wir mal davon aus, dass Schwarz(0,0,0,255/2) ist und das auf ein Rot(255,0,0,255) angewandt wird dann folgt daraus ein Rot,welches um die Hälfte dunkler ist, also da dann zu einem entsprechenden anteil blau und gelb/grün reingemischt sind... Irgendwie so... würde ich mir das zumindest vorstellen...<br />
Am besten spielt man dazu erstmal ein bisschen mit Hexfarbwerten rum und schaut die sich in einem entsprechenden Viewer an um dann abschätzen zu können zu welchem anteil bei welcher Verdunklung andere Farben mit rein gemacht werden müssen oder auch nicht.... So in etwa? Bin in diesem Thema relativ jung unterwegs, daher kann das auch komplett falsch sein... Aber es sind meine Übelegungen dazu...</p>
<p>EDIT: Wobei ja dann weniger Rotwert auch auf dunkler schließen lässt und man somit nur den rot wert um die hälfte verringern müsste... also um den Transparenz wert, den Schwarz hat verringern und bei Weiß muss man dann aber glaub ich andere Farben dazumischen damits heller wird... wie z.B. HellRed(255,100,100,255) oder so...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890830</guid><dc:creator><![CDATA[Blackskyliner]]></dc:creator><pubDate>Sat, 01 May 2010 10:49:33 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 10:50:32 GMT]]></title><description><![CDATA[<p>Hi.<br />
Stimmt, dass habe ich so noch gar nicht gesehen.</p>
<p>Hier ist meine aktuelle Lösung um erstmal nur die Farbwerte herauszubekommen. Helligkeit wird dabei noch nicht beachtet:</p>
<pre><code class="language-cpp">if (this-&gt;m_iX &lt; 43)
{
	this-&gt;m_clrTemp.set(255, this-&gt;m_iX * 6, 0, 255);
}
else if (this-&gt;m_iX &lt; 86)
{
	this-&gt;m_clrTemp.set(255 - this-&gt;m_iX * 6, 255, 0, 255);
}
else if (this-&gt;m_iX &lt; 129)
{
	this-&gt;m_clrTemp.set(0, 255, this-&gt;m_iX * 6, 255);
}
else if (this-&gt;m_iX &lt; 172)
{
	this-&gt;m_clrTemp.set(0, 255 - this-&gt;m_iX * 6, 255, 255);
}
else if (this-&gt;m_iX &lt; 215)
{
	this-&gt;m_clrTemp.set(this-&gt;m_iX * 6, 0, 255, 255);
}
else
{
	this-&gt;m_clrTemp.set(255, 0, 255 - this-&gt;m_iX * 6, 255);
}

// this-&gt;m_iX ist die aktuelle X-Position des Cursors
</code></pre>
<p>Sieht mir alles etwas murksig aus, vielleicht geht das ja noch einfacher. Aber was anderes kriege ich gerade nicht hin <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Ich probier mal weiter herum.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890831</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Sat, 01 May 2010 10:50:32 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 16:53:48 GMT]]></title><description><![CDATA[<p>Och würde sagen, mit den Farbwerten ist das so:<br />
Alte Farbe r, g, b (im Beispiel rot, also 255, 0, 0)<br />
Überdeckungsfarbe: r2, g2, b2, a2 (im Beispiel halbtransparentes schwarz, also 0, 0, 0 , 127)</p>
<p>Neue Farbe: r3, g3, b3</p>
<pre><code>r3 = (255 - a2) / 255  * r  +  a2 / 255 * r2
</code></pre>
<p>Analog für g3, b3.</p>
<p>Im Beispiel wäre das also:</p>
<pre><code>r3 = 0.5 * 255 + 0.5 * 0  = 127
 g3 = 0.5 * 0 + 0.5 * 0    =   0
 b3 = 0.5 * 0 + 0.5 * 0    =   0
</code></pre>
<p>es kommt also ein halb so helles rot raus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1890997</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1890997</guid><dc:creator><![CDATA[ngc92]]></dc:creator><pubDate>Sat, 01 May 2010 16:53:48 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sat, 01 May 2010 19:35:13 GMT]]></title><description><![CDATA[<p>Und wie sieht das dann bei helleren Farben aus, also heller als rot(255,0,0,255)?<br />
Kommen dann andere Farbspektren dazu um halt additiv Richtung weiß zu kommen oder spielt man da dann mit der Transparenz?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1891057</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1891057</guid><dc:creator><![CDATA[Blackskyliner]]></dc:creator><pubDate>Sat, 01 May 2010 19:35:13 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sun, 02 May 2010 12:14:56 GMT]]></title><description><![CDATA[<p>na, wenn man rot + weiß (50% transparent) rechnet, kommt ein helleres rot raus:</p>
<p>[code]<br />
r3 = 0.5 * 255 + 0.5 * 255 = 255<br />
g3 = 0.5 * 0 + 0.5 * 255 = 127<br />
b3 = 0.5 * 0 + 0.5 * 255 = 127<br />
[\code]</p>
<p>gibt ein schönes schweinchenrosa.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1891305</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1891305</guid><dc:creator><![CDATA[ngc92]]></dc:creator><pubDate>Sun, 02 May 2010 12:14:56 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sun, 02 May 2010 12:37:57 GMT]]></title><description><![CDATA[<p>Hi.<br />
Danke!<br />
Habe mal versuchst das umzusetzen. Entweder ich mache was falsch oder die Berechnung stimmt leider doch nicht.</p>
<p>Hier ist der Code:</p>
<pre><code class="language-cpp">this-&gt;m_clrTemp.set(
  /*rot*/(255 - this-&gt;m_iY) / 255 * this-&gt;m_clrTemp.r() + this-&gt;m_iY / 255 * 255,
  /*gruen*/(255 - this-&gt;m_iY) / 255 * this-&gt;m_clrTemp.g() + this-&gt;m_iY / 255 * 255,
  /*blau*/(255 - this-&gt;m_iY) / 255 * this-&gt;m_clrTemp.b() + this-&gt;m_iY / 255 * 255,
  /*alpha*/255);
</code></pre>
<p>Das ist jetzt für oben (also das weiße). Die resultierende Farbe ist aber leider immer Schwarz.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1891314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1891314</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Sun, 02 May 2010 12:37:57 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sun, 02 May 2010 13:02:07 GMT]]></title><description><![CDATA[<p>Du rechnest ja auch immer mit Integerwerten.<br />
Was ergibt dann z.B. &quot;this-&gt;m_iY / 255&quot; ? -)</p>
<p>Statt jedoch auf Float bzw. Double zu wechseln, solltest du einfach die Formel anpassen:</p>
<pre><code>r3 = ((255 - a2) * r  +  a2 * r2) / 255
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1891323</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1891323</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Sun, 02 May 2010 13:02:07 GMT</pubDate></item><item><title><![CDATA[Reply to Farbe herausbekommen am Farbspektrum? on Sun, 02 May 2010 13:28:59 GMT]]></title><description><![CDATA[<p>Hi.<br />
Danke - das sieht schon sehr viel besser aus. Allerdings ist das Problem, dass er ganz oben im Spektrum Rot anzeigt, und in der Mitte weiß (müsste anders herum). Ich habe bereits alle möglichen Kombinationen mit + und - 255 probiert, aber dann passt das alles nicht mehr.</p>
<p>Und mit schwarz geht es leider auch gar nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":/"
      alt="😕"
    /></p>
<pre><code class="language-cpp">// m_iY &lt; 256 - weiß
this-&gt;m_clrTemp.SetColor(
	((255 - this-&gt;m_iY) * this-&gt;m_clrTemp.r() + (this-&gt;m_iY) * 255) / 255,
	((255 - this-&gt;m_iY) * this-&gt;m_clrTemp.g() + (this-&gt;m_iY) * 255) / 255,
	((255 - this-&gt;m_iY) * this-&gt;m_clrTemp.b() + (this-&gt;m_iY) * 255) / 255, 255);

// m_iY &gt; 256 - schwarz
this-&gt;m_clrTemp.SetColor(
	((255 - this-&gt;m_iY) * this-&gt;m_clrTemp.r() + this-&gt;m_iY * 0) / 255,
	((255 - this-&gt;m_iY) * this-&gt;m_clrTemp.g() + this-&gt;m_iY * 0) / 255,
	((255 - this-&gt;m_iY) * this-&gt;m_clrTemp.b() + this-&gt;m_iY * 0) / 255, 255);
</code></pre>
<p>Gruß und Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1891335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1891335</guid><dc:creator><![CDATA[theliquidwave]]></dc:creator><pubDate>Sun, 02 May 2010 13:28:59 GMT</pubDate></item></channel></rss>