<?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[Ausgabe in binär ändern (Bildbearbeitung)]]></title><description><![CDATA[<p>Hallo zusammen,<br />
beim Schreiben eines Programmes zur Bildbearbeitung habe ich folgenden Ausgabeoperator geschrieben:</p>
<pre><code class="language-cpp">ostream&amp; operator &lt;&lt; (ostream &amp;s, const GreyScale &amp;g)
{

	int form = g.format;
	switch (form)
	{		

	case 0:{ 	// ASCII_PGM

		s	&lt;&lt; &quot;P2\n&quot;
			&lt;&lt; &quot;# Neues Bild im ASCII PGM Format (0)\n&quot;
			&lt;&lt; g.width &lt;&lt; ' ' &lt;&lt;  g.height &lt;&lt; &quot;\n&quot;
			&lt;&lt; 255 &lt;&lt; &quot;\n&quot;;

		int j=16;
		for (int i=0; i&lt;g.width*g.height; i++)
		{
			if(j==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				j=16;
			}
			j--;
			s &lt;&lt; (int)round(g.farbe[i]*255)  &lt;&lt; ' ';
		}

		break;}

	case 1:{	// PGM_RAW

		s	&lt;&lt; &quot;P5 &quot;
			&lt;&lt; &quot;# Neues Bild im PGM_RAW Format (1)\n&quot;
			&lt;&lt; g.width &lt;&lt; ' ' &lt;&lt; g.height &lt;&lt; &quot; &quot; &lt;&lt; 255 &lt;&lt; &quot;\n&quot;;

		int j=g.width;
		for (int i=0; i&lt;g.width*g.height; i++)
		{
			if(j==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				j=g.width;
			}
			j--;
			s &lt;&lt; (int)round(g.farbe[i]*255) &lt;&lt; ' ';
		}

		break;}

	case 2:{ 	// HUFFMAN

		s	&lt;&lt; &quot;MHa\n&quot;
			&lt;&lt; &quot;# Neues Bild im Huffman-Code \n&quot;;

		GreyScale hilf(g);

		s &lt;&lt; g.width &lt;&lt; ' ' &lt;&lt; g.height &lt;&lt; &quot;\n&quot;;

		hilf.BuildHist();		

		for (int i=0; i&lt;=255; i++)
		{
			s &lt;&lt; hilf.hist[i];
			if (i==255)
				s &lt;&lt; &quot;\n&quot;;
			else
				s &lt;&lt; &quot; &quot;;
		}

		hilf.BuildHuff();
		int k=g.width;

		for (int j=0; j&lt;g.width*g.height;j++)
		{
			if(k==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				k=g.width;
			}
			s &lt;&lt; hilf.gethuff((int)round(hilf.farbe[j]*255)) &lt;&lt; ' ';
			k--;
		}

		break;}

	case 3:	{

	s	&lt;&lt; &quot;MHb\n&quot;
		&lt;&lt; &quot;# Neues Bild im Huffman-Code mit Transformation \n&quot;;

	GreyScale hilf(g);
	hilf.transform();

	s &lt;&lt; g.width &lt;&lt; ' ' &lt;&lt; g.height &lt;&lt; &quot;\n&quot;;

		hilf.BuildHist();		

		for (int i=0; i&lt;=255; i++)
		{
			s &lt;&lt; hilf.hist[i];
			if (i==255)
				s &lt;&lt; &quot;\n&quot;;
			else
				s &lt;&lt; &quot; &quot;;
		}

		hilf.BuildHuff();
		int k=16;

		for (int j=0; j&lt;g.width*g.height;j++)
		{
			if(k==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				k=16;
			}
			s &lt;&lt; hilf.gethuff((int)round(hilf.farbe[j]*255)) &lt;&lt; ' ';
		}

		break;}

		// HUFFMAN_TRANSFORM

	default: 	g.GreyScaleFehler(&quot;Illegales Format! Sofort stehen bleiben!&quot;);

	}
	return s &lt;&lt; &quot;\n&quot;;
}
</code></pre>
<p>Jetzt würde ich die Ausgabe gerne in binär haben. Hätte da irgendjemand nen Tipp, wie ich da vorgehen kann?<br />
Dankeschön schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/217537/ausgabe-in-binär-ändern-bildbearbeitung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 14:57:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/217537.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Jul 2008 14:35:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ausgabe in binär ändern (Bildbearbeitung) on Tue, 08 Jul 2008 14:35:34 GMT]]></title><description><![CDATA[<p>Hallo zusammen,<br />
beim Schreiben eines Programmes zur Bildbearbeitung habe ich folgenden Ausgabeoperator geschrieben:</p>
<pre><code class="language-cpp">ostream&amp; operator &lt;&lt; (ostream &amp;s, const GreyScale &amp;g)
{

	int form = g.format;
	switch (form)
	{		

	case 0:{ 	// ASCII_PGM

		s	&lt;&lt; &quot;P2\n&quot;
			&lt;&lt; &quot;# Neues Bild im ASCII PGM Format (0)\n&quot;
			&lt;&lt; g.width &lt;&lt; ' ' &lt;&lt;  g.height &lt;&lt; &quot;\n&quot;
			&lt;&lt; 255 &lt;&lt; &quot;\n&quot;;

		int j=16;
		for (int i=0; i&lt;g.width*g.height; i++)
		{
			if(j==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				j=16;
			}
			j--;
			s &lt;&lt; (int)round(g.farbe[i]*255)  &lt;&lt; ' ';
		}

		break;}

	case 1:{	// PGM_RAW

		s	&lt;&lt; &quot;P5 &quot;
			&lt;&lt; &quot;# Neues Bild im PGM_RAW Format (1)\n&quot;
			&lt;&lt; g.width &lt;&lt; ' ' &lt;&lt; g.height &lt;&lt; &quot; &quot; &lt;&lt; 255 &lt;&lt; &quot;\n&quot;;

		int j=g.width;
		for (int i=0; i&lt;g.width*g.height; i++)
		{
			if(j==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				j=g.width;
			}
			j--;
			s &lt;&lt; (int)round(g.farbe[i]*255) &lt;&lt; ' ';
		}

		break;}

	case 2:{ 	// HUFFMAN

		s	&lt;&lt; &quot;MHa\n&quot;
			&lt;&lt; &quot;# Neues Bild im Huffman-Code \n&quot;;

		GreyScale hilf(g);

		s &lt;&lt; g.width &lt;&lt; ' ' &lt;&lt; g.height &lt;&lt; &quot;\n&quot;;

		hilf.BuildHist();		

		for (int i=0; i&lt;=255; i++)
		{
			s &lt;&lt; hilf.hist[i];
			if (i==255)
				s &lt;&lt; &quot;\n&quot;;
			else
				s &lt;&lt; &quot; &quot;;
		}

		hilf.BuildHuff();
		int k=g.width;

		for (int j=0; j&lt;g.width*g.height;j++)
		{
			if(k==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				k=g.width;
			}
			s &lt;&lt; hilf.gethuff((int)round(hilf.farbe[j]*255)) &lt;&lt; ' ';
			k--;
		}

		break;}

	case 3:	{

	s	&lt;&lt; &quot;MHb\n&quot;
		&lt;&lt; &quot;# Neues Bild im Huffman-Code mit Transformation \n&quot;;

	GreyScale hilf(g);
	hilf.transform();

	s &lt;&lt; g.width &lt;&lt; ' ' &lt;&lt; g.height &lt;&lt; &quot;\n&quot;;

		hilf.BuildHist();		

		for (int i=0; i&lt;=255; i++)
		{
			s &lt;&lt; hilf.hist[i];
			if (i==255)
				s &lt;&lt; &quot;\n&quot;;
			else
				s &lt;&lt; &quot; &quot;;
		}

		hilf.BuildHuff();
		int k=16;

		for (int j=0; j&lt;g.width*g.height;j++)
		{
			if(k==0)
			{
				s &lt;&lt; &quot;\n&quot;;
				k=16;
			}
			s &lt;&lt; hilf.gethuff((int)round(hilf.farbe[j]*255)) &lt;&lt; ' ';
		}

		break;}

		// HUFFMAN_TRANSFORM

	default: 	g.GreyScaleFehler(&quot;Illegales Format! Sofort stehen bleiben!&quot;);

	}
	return s &lt;&lt; &quot;\n&quot;;
}
</code></pre>
<p>Jetzt würde ich die Ausgabe gerne in binär haben. Hätte da irgendjemand nen Tipp, wie ich da vorgehen kann?<br />
Dankeschön schonmal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1543526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1543526</guid><dc:creator><![CDATA[sesamstraße]]></dc:creator><pubDate>Tue, 08 Jul 2008 14:35:34 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe in binär ändern (Bildbearbeitung) on Tue, 08 Jul 2008 14:44:24 GMT]]></title><description><![CDATA[<p>code-tags ftw <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1543532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1543532</guid><dc:creator><![CDATA[sothis_]]></dc:creator><pubDate>Tue, 08 Jul 2008 14:44:24 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe in binär ändern (Bildbearbeitung) on Tue, 08 Jul 2008 15:28:38 GMT]]></title><description><![CDATA[<p>In ein File kannst du das angeben, dass er binär schreiben soll.</p>
<p><a href="http://www.cplusplus.com/reference/iostream/ofstream/ofstream.html" rel="nofollow">http://www.cplusplus.com/reference/iostream/ofstream/ofstream.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1543563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1543563</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Tue, 08 Jul 2008 15:28:38 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe in binär ändern (Bildbearbeitung) on Tue, 08 Jul 2008 21:02:55 GMT]]></title><description><![CDATA[<p>Oki. ich erkläre mich jetzt offziell für zu dämlich dafür. Hab mal den ersten Teil folgendermaßen umgeschrieben:</p>
<pre><code>ofstream GreyscaleO;

void ofstream::open(const char *Greyscale, ios::openmode mode=ios::binary|ios::out);
{
	GreyscaleO.write (&quot;P5 &quot;);
	  		GreyscaleO.write(&quot;# Neues Bild im PGM_RAW Format (1)&quot;);
			GreyscaleO.write ( g.width &lt;&lt; ' ' &lt;&lt; g.height &lt;&lt; &quot; &quot; &lt;&lt; 255 &lt;&lt; &quot; /n&quot;);

		int j=g.width;
		for (int i=0; i&lt;g.width*g.height; i++)
		{
			if(j==0)
			{
				GreyscaleO.write( &quot;/n &quot;);
				j=g.width;
			}
			j--;
			s &lt;&lt; (int)round(g.farbe[i]*255) &lt;&lt; ' ';
		}
</code></pre>
<p>Aber das kanns nicht gewesen sein, oder? Im Moment hab ich noch das Problem, dass ich hier an nem compilerlosen Rechner sitze und deshalb sich die Möglichkeit der Überprüfung nicht bietet. Aber das ist ziemlich sicher falsch...</p>
<p>(und ich scheiter schon an den Code Tags...Ich brech zusammen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1543805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1543805</guid><dc:creator><![CDATA[sesamstraße]]></dc:creator><pubDate>Tue, 08 Jul 2008 21:02:55 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe in binär ändern (Bildbearbeitung) on Tue, 08 Jul 2008 21:14:43 GMT]]></title><description><![CDATA[<p>Sind die code/cpp-Tags kaputt oder wie?</p>
<pre><code>test
</code></pre>
<pre><code class="language-cpp">void &amp;main(void*,float*);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1543809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1543809</guid><dc:creator><![CDATA[test123]]></dc:creator><pubDate>Tue, 08 Jul 2008 21:14:43 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabe in binär ändern (Bildbearbeitung) on Tue, 08 Jul 2008 21:53:21 GMT]]></title><description><![CDATA[<p>[ cpp]<br />
&lt;hier code&gt;<br />
[/ cpp]</p>
<p>wenn du die lerzeichen weglässt, dann sieht es auch so toll aus, wie</p>
<p>test123 schrieb:</p>
<blockquote>
<pre><code class="language-cpp">void &amp;main(void*,float*); //interessant ^^
</code></pre>
</blockquote>
<p>musste ich einfach ma quoten ; D</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1543825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1543825</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Tue, 08 Jul 2008 21:53:21 GMT</pubDate></item></channel></rss>