<?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[Image aus Buffer zeichnen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte eine Bitmap aus einem File in einen Buffer schreiben und dann als<br />
Bild ausgeben.</p>
<p>Image1-&gt;Picture-&gt;LoadFromFile(&quot;Bitmap1.bmp&quot;); //Funktioniert</p>
<p>Wie kann ich nun aber Image1 eine Bitmap aus dem Speicher zuweisen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/93941/image-aus-buffer-zeichnen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 16:04:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/93941.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Dec 2004 13:16:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sat, 04 Dec 2004 13:16:15 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte eine Bitmap aus einem File in einen Buffer schreiben und dann als<br />
Bild ausgeben.</p>
<p>Image1-&gt;Picture-&gt;LoadFromFile(&quot;Bitmap1.bmp&quot;); //Funktioniert</p>
<p>Wie kann ich nun aber Image1 eine Bitmap aus dem Speicher zuweisen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665727</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Sat, 04 Dec 2004 13:16:15 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sat, 04 Dec 2004 14:20:44 GMT]]></title><description><![CDATA[<p>Ich habe nun folgendes gemacht, was ganz gut funkt.<br />
Ich lese von Winamp die aktuelle Position des Tracks in ms und gebe diese<br />
dann über meine selbstgezeichneten 7Segment Anzeigen aus.<br />
Das ganze scheint mir etwas umständlich, gibs vieleicht eine einfachere<br />
Lösung?</p>
<pre><code class="language-cpp">HWND hwndWinamp;
Graphics::TBitmap* Bmp0;
Graphics::TBitmap* Bmp1;
Graphics::TBitmap* Bmp2;
Graphics::TBitmap* Bmp3;
Graphics::TBitmap* Bmp4;
Graphics::TBitmap* Bmp5;
Graphics::TBitmap* Bmp6;
Graphics::TBitmap* Bmp7;
Graphics::TBitmap* Bmp8;
Graphics::TBitmap* Bmp9;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
     : TForm(Owner)
{
    Bmp0 = new Graphics::TBitmap();
    Bmp1 = new Graphics::TBitmap();
    Bmp2 = new Graphics::TBitmap();
    Bmp3 = new Graphics::TBitmap();
    Bmp4 = new Graphics::TBitmap();
    Bmp5 = new Graphics::TBitmap();
    Bmp6 = new Graphics::TBitmap();
    Bmp7 = new Graphics::TBitmap();
    Bmp8 = new Graphics::TBitmap();
    Bmp9 = new Graphics::TBitmap();
    Bmp0-&gt;LoadFromFile(&quot;Bitmap0.bmp&quot;);
    Bmp1-&gt;LoadFromFile(&quot;Bitmap1.bmp&quot;);
    Bmp2-&gt;LoadFromFile(&quot;Bitmap2.bmp&quot;);
    Bmp3-&gt;LoadFromFile(&quot;Bitmap3.bmp&quot;);
    Bmp4-&gt;LoadFromFile(&quot;Bitmap4.bmp&quot;);
    Bmp5-&gt;LoadFromFile(&quot;Bitmap5.bmp&quot;);
    Bmp6-&gt;LoadFromFile(&quot;Bitmap6.bmp&quot;);
    Bmp7-&gt;LoadFromFile(&quot;Bitmap7.bmp&quot;);
    Bmp8-&gt;LoadFromFile(&quot;Bitmap8.bmp&quot;);
    Bmp9-&gt;LoadFromFile(&quot;Bitmap9.bmp&quot;);
    hwndWinamp = FindWindow(&quot;Winamp v1.x&quot;,NULL);
    TrackBar1Change(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
    SendMessage(hwndWinamp,WM_USER,((TrackBar1-&gt;Position-255)*-1),122);     //Winamp Lautstärke
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
     unsigned int time;
     time =(SendMessage(hwndWinamp,WM_USER,0,105)/100);//Aktuelle Trackzeit in ms
     Edit1-&gt;Text = time;
     time = hex_to_dec(time);
     draw_num(Image1,(time&amp;0x0f));
     draw_num(Image2,(time&gt;&gt;4)&amp;0x0f);
     draw_num(Image3,(time&gt;&gt;8)&amp;0x0f);
     draw_num(Image4,(time&gt;&gt;12)&amp;0x0f);
     draw_num(Image5,(time&gt;&gt;16)&amp;0x000f);

}
//---------------------------------------------------------------------------
int __fastcall TForm1::hex_to_dec(int int_num)
{
     int result;
     asm
     {
          mov  ecx,0
          mov  ebx,10
          mov  edi,0
          mov  eax,int_num
next:
          xor  edx,edx
          div  ebx
          and  edx,0x0f
          shl  edx,cl
          or   edi,edx
          add  ecx,4
          cmp  eax,0
          jne next
          mov  result,edi
     }
     return result;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::draw_num(TImage* image,char number)
{
     if(number == 0)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp0;
     }
     else if(number == 1)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp1;
     }
     else if(number == 2)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp2;
     }
     else if(number == 3)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp3;
     }
     else if(number == 4)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp4;
     }
     else if(number == 5)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp5;
     }
     else if(number == 6)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp6;
     }
     else if(number == 7)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp7;
     }
     else if(number == 8)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp8;
     }
     else if(number == 9)
     {
          image-&gt;Picture-&gt;Bitmap=Bmp9;
     }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &amp;Action)
{

     delete Bmp0;
     delete Bmp1;
     delete Bmp2;
     delete Bmp3;
     delete Bmp4;
     delete Bmp5;
     delete Bmp6;
     delete Bmp7;
     delete Bmp8;
     delete Bmp9;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/665776</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665776</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Sat, 04 Dec 2004 14:20:44 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sat, 04 Dec 2004 15:40:28 GMT]]></title><description><![CDATA[<p>Hallo</p>
<blockquote>
<p>Wie kann ich nun aber Image1 eine Bitmap aus dem Speicher zuweisen?</p>
</blockquote>
<p>...-&gt;Canvas-&gt;Draw(x,y,TBitmap);</p>
<p>zu deinem Programm :<br />
Mach ein Array aus deinen Bitmaps :</p>
<pre><code>Graphics::TBitmap* Bmps[10];
...
for (int Lv = 0; Lv &lt; 10; Lv++) 
{
  Bmps[Lv] = new Graphics::TBitmap();
  Bmps[Lv]-&gt;LoadFromFile(&quot;Bitmap&quot; + IntToStr(Lv) + &quot;.bmp&quot;);
  }
...
  image-&gt;Picture-&gt;Bitmap=Bmps[number];
...
for (int Lv = 0; Lv &lt; 10; Lv++) 
{
  delete Bmps[Lv];
  }
</code></pre>
<p>außerdem solltest du dir mal <em>switch</em> anschauen.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665823</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 04 Dec 2004 15:40:28 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sat, 04 Dec 2004 15:44:54 GMT]]></title><description><![CDATA[<p>hermes schrieb:</p>
<blockquote>
<p>gibs vieleicht eine einfachere Lösung?</p>
</blockquote>
<p>Benutze eine ImageList (Reiter 'Win32').</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665825</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Sat, 04 Dec 2004 15:44:54 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sat, 04 Dec 2004 19:05:47 GMT]]></title><description><![CDATA[<p>Danke für den Hinweis.</p>
<p>Gibt es eigentlich auch eine andere Lösung die Bitmaps zu schreiben, bei der<br />
o.a. Methode flackert die Anzeige ständig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665921</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665921</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Sat, 04 Dec 2004 19:05:47 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sat, 04 Dec 2004 19:10:06 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>schau dir diesen Thread an :<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=93888" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic.php?t=93888</a></p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665924</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665924</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 04 Dec 2004 19:10:06 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sun, 05 Dec 2004 13:26:19 GMT]]></title><description><![CDATA[<p>Das ganze ohne flackern und wesentlich kürzer.</p>
<pre><code class="language-cpp">WND hwndWinamp;
Graphics::TBitmap* Bmps[10];
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
     : TForm(Owner)
{
     hwndWinamp = FindWindow(&quot;Winamp v1.x&quot;,NULL);
     TrackBar1Change(NULL);
     for (int Lv = 0; Lv &lt; 10; Lv++)
     {
          Bmps[Lv] = new Graphics::TBitmap();
          Bmps[Lv]-&gt;LoadFromFile(&quot;Bitmap&quot; + IntToStr(Lv) + &quot;.bmp&quot;);
     }
     DoubleBuffered = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::draw_num(TImage* image,char number)
{
   image-&gt;Picture-&gt;Bitmap =Bmps[number];
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TrackBar1Change(TObject *Sender)
{
    SendMessage(hwndWinamp,WM_USER,((TrackBar1-&gt;Position-255)*-1),122);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
     unsigned int time;
     time =(SendMessage(hwndWinamp,WM_USER,0,105)/100);
     time = hex_to_dec(time);
     draw_num(Image1,(time&amp;0x0f));
     draw_num(Image2,(time&gt;&gt;4)&amp;0x0f);
     draw_num(Image3,(time&gt;&gt;8)&amp;0x0f);
     draw_num(Image4,(time&gt;&gt;12)&amp;0x0f);
     draw_num(Image5,(time&gt;&gt;16)&amp;0x000f);
}
//---------------------------------------------------------------------------
int __fastcall TForm1::hex_to_dec(int int_num)
{
     int result;
     asm
     {
          mov  ecx,0
          mov  ebx,10
          mov  edi,0
          mov  eax,int_num
next:
          xor  edx,edx
          div  ebx
          and  edx,0x0f
          shl  edx,cl
          or   edi,edx
          add  ecx,4
          cmp  eax,0
          jne next
          mov  result,edi
     }
     return result;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &amp;Action)
{
     for (int Lv = 0; Lv &lt; 10; Lv++)
     {
          delete Bmps[Lv];
     }
}
</code></pre>
<p>Danke für die Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/666011</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/666011</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Sun, 05 Dec 2004 13:26:19 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Sun, 05 Dec 2004 09:04:04 GMT]]></title><description><![CDATA[<p>DoubleBuffered muss nur einmal gesetzt werden.<br />
Und TImageList solltest du dir trotzdem nochmal ansehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/666104</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/666104</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Sun, 05 Dec 2004 09:04:04 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Mon, 06 Dec 2004 20:14:39 GMT]]></title><description><![CDATA[<p>Wie würde ich nun eine Komponente &quot;7Segment&quot; erstellen.<br />
Was müsste ich in der überschriebenen Methode Paint tun, wenn anhand<br />
der Eigenschaft Number die entsprechende Bitmap dargestellt werden soll?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667555</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667555</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Mon, 06 Dec 2004 20:14:39 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Mon, 06 Dec 2004 20:23:38 GMT]]></title><description><![CDATA[<p>Hallo</p>
<blockquote>
<p>Wie würde ich nun eine Komponente &quot;7Segment&quot; erstellen.<br />
Was müsste ich in der überschriebenen Methode Paint tun, wenn anhand<br />
der Eigenschaft Number die entsprechende Bitmap dargestellt werden soll?</p>
</blockquote>
<p>Ich würde von TImage ableiten. Als __property<br />
- eine Referenz auf eine externe TImageList, die alle Bitmaps enthält. Ohne zugewiesene ImageListe entweder leer oder Exception<br />
- unsingned int als Wert, der gerade dargestellt wird. Im Setter dieser Property kannst du (wenn TImageList vorhanden ist) das entsprechende Bitmap in das eigentliche Bitmap des TImages schreiben (TImage-&gt;Canvas-&gt;Draw(0,0,&lt;Bitmap für neuen Wert&gt;).</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/667565</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/667565</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Mon, 06 Dec 2004 20:23:38 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Tue, 07 Dec 2004 22:49:07 GMT]]></title><description><![CDATA[<p>Habe mit ImageList rumprobiert und kein vernüftiges Ergebniss bekommen.</p>
<p>Mit doppelklick auf die ImageList Komponente eine Bitmap hinzugefügt und<br />
dann mit</p>
<p>ImageList1-&gt;GetBitmap(0,Image1-&gt;Picture-&gt;Bitmap);</p>
<p>ausgegeben.</p>
<p>Das Ergebniss sieht nicht so wie erwartet aus (zu klein und verzerrt).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/668485</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/668485</guid><dc:creator><![CDATA[hermes]]></dc:creator><pubDate>Tue, 07 Dec 2004 22:49:07 GMT</pubDate></item><item><title><![CDATA[Reply to Image aus Buffer zeichnen on Wed, 08 Dec 2004 05:57:57 GMT]]></title><description><![CDATA[<p>Hi,<br />
hasst du auch Width und Height der ImageList angepasst?</p>
<p>MfG</p>
<p>Alexander Sulfrian</p>
]]></description><link>https://www.c-plusplus.net/forum/post/668523</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/668523</guid><dc:creator><![CDATA[Alexander Sulfrian]]></dc:creator><pubDate>Wed, 08 Dec 2004 05:57:57 GMT</pubDate></item></channel></rss>