<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Create Bitmap on runtime' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Create Bitmap on runtime' posted on the 'Computer Graphics' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 23:36:52 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 23:36:52 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Create Bitmap on runtime</title>
      <link>http://www.programmersheaven.com/mb/graphics/362469/362469/create-bitmap-on-runtime/</link>
      <description>Hi,&lt;br /&gt;
&lt;br /&gt;
I'm attempting to use c++, windows api GDI, to create a bitmap of something I  painted on the screen.  Once I create the bitmap I want to be able to move it about the window.&lt;br /&gt;
&lt;br /&gt;
I couldn't find anything too great on google about it, so I broke down and I'm asking for your help.&lt;br /&gt;
&lt;br /&gt;
If you don't know, possibly if you point me in the direction of a tutorial/code of how to make mspaint, I'd be able to figure it out.&lt;br /&gt;
&lt;br /&gt;
Thanks.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/graphics/362469/362469/create-bitmap-on-runtime/</guid>
      <pubDate>Fri, 29 Jun 2007 08:10:42 -0700</pubDate>
      <category>Computer Graphics</category>
    </item>
    <item>
      <title>Re: Create Bitmap on runtime</title>
      <link>http://www.programmersheaven.com/mb/graphics/362469/362892/re-create-bitmap-on-runtime/#362892</link>
      <description>: Hi,&lt;br /&gt;
: &lt;br /&gt;
: I'm attempting to use c++, windows api GDI, to create a bitmap of &lt;br /&gt;
: something I  painted on the screen.  Once I create the bitmap I want &lt;br /&gt;
: to be able to move it about the window.&lt;br /&gt;
: &lt;br /&gt;
: I couldn't find anything too great on google about it, so I broke &lt;br /&gt;
: down and I'm asking for your help.&lt;br /&gt;
: &lt;br /&gt;
: If you don't know, possibly if you point me in the direction of a &lt;br /&gt;
: tutorial/code of how to make mspaint, I'd be able to figure it out.&lt;br /&gt;
: &lt;br /&gt;
: Thanks.&lt;br /&gt;
: &lt;br /&gt;
If you run Windows, the Windows API provides you with several bitmap operations which suit your needs.&lt;br /&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/ms532343.aspx"&gt;http://msdn2.microsoft.com/en-us/library/ms532343.aspx&lt;/a&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/graphics/362469/362892/re-create-bitmap-on-runtime/#362892</guid>
      <pubDate>Sat, 07 Jul 2007 07:53:53 -0700</pubDate>
      <category>Computer Graphics</category>
    </item>
    <item>
      <title>Re: Create Bitmap on runtime</title>
      <link>http://www.programmersheaven.com/mb/graphics/362469/362919/re-create-bitmap-on-runtime/#362919</link>
      <description>&lt;span style="color: Blue;"&gt;&lt;br /&gt;
1. Get a device context of the area you trying to snap shoot.&lt;br /&gt;
    - use GetDC()&lt;br /&gt;
&lt;br /&gt;
2. Create a DC compatible with DC from step 1.&lt;br /&gt;
    - use CreateCompatibleDC()&lt;br /&gt;
&lt;br /&gt;
3. Create a bitmap handle compatible with DC from step 1.&lt;br /&gt;
You will need to know the area size (width and height)&lt;br /&gt;
    - use CreateCompatibleBitmap()&lt;br /&gt;
&lt;br /&gt;
4. Select HBITMAP from step 3 into DC from step 2. You need&lt;br /&gt;
to preserve the return value (it is HBITMAP) of this operation.&lt;br /&gt;
    - use SelectObject()&lt;br /&gt;
&lt;br /&gt;
5. Make a snap shot of the area.&lt;br /&gt;
    - use BitBlt()&lt;br /&gt;
    - the source DC is from step 1&lt;br /&gt;
    - the destination DC is from step 2&lt;br /&gt;
    - the coordinates and size will define the area itself&lt;br /&gt;
&lt;br /&gt;
6. Restore the HBITMAP in a DC from step 2 - use the returned value&lt;br /&gt;
in a call to SelectObject()&lt;br /&gt;
&lt;br /&gt;
7. Get rid of DC from step 2&lt;br /&gt;
    - use DeleteDC()&lt;br /&gt;
&lt;br /&gt;
===&lt;br /&gt;
&lt;br /&gt;
That's it - at this point you left with HBITMAP created in step 3 and it has the image of the are you need, so you can draw it somewhere else or save it as a file. To save it - you need to do more stuff...&lt;br /&gt;
&lt;br /&gt;
When you finished with HBITMAP - do not forget to dismiss it using DeleteObject() function.&lt;br /&gt;
&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/graphics/362469/362919/re-create-bitmap-on-runtime/#362919</guid>
      <pubDate>Sun, 08 Jul 2007 04:14:14 -0700</pubDate>
      <category>Computer Graphics</category>
    </item>
    <item>
      <title>Re: Create Bitmap on runtime</title>
      <link>http://www.programmersheaven.com/mb/graphics/362469/362959/re-create-bitmap-on-runtime/#362959</link>
      <description>Thanks to both of you.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/graphics/362469/362959/re-create-bitmap-on-runtime/#362959</guid>
      <pubDate>Mon, 09 Jul 2007 05:21:50 -0700</pubDate>
      <category>Computer Graphics</category>
    </item>
    <item>
      <title>Re: Create Bitmap on runtime</title>
      <link>http://www.programmersheaven.com/mb/graphics/362469/368570/re-create-bitmap-on-runtime/#368570</link>
      <description>: Thanks to both of you.&lt;br /&gt;
: &lt;br /&gt;
I made a c++ class for working with the bitmap format.  It works independent of the Windows API, though.&lt;br /&gt;
&lt;br /&gt;
You can get the c++ source code here:&lt;br /&gt;
&lt;a href="http://www.programmersheaven.com/d/click.aspx?ID=F54666"&gt;http://www.programmersheaven.com/d/click.aspx?ID=F54666&lt;/a&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/graphics/362469/368570/re-create-bitmap-on-runtime/#368570</guid>
      <pubDate>Fri, 11 Jan 2008 09:06:01 -0700</pubDate>
      <category>Computer Graphics</category>
    </item>
  </channel>
</rss>