Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First you may try <code>dynamic_cast</code> as in many cases (if not most - at least in my use cases) <code>Image</code> indeed is a <code>Bitmap</code>. So</p> <pre><code>Image* img = getThumbnail( /* ... */ ); Bitmap* bitmap = dynamic_cast&lt;Bitmap*&gt;(img); if(!bitmap) // getThumbnail returned an Image which is not a Bitmap. Convert. else // getThumbnail returned a Bitmap so just deal with it. </code></pre> <p>However if somehow it is not (<code>bitmap</code> will be <code>NULL</code>) then you could try a more general solution.</p> <p>For example save the <code>Image</code> to a <em>COM</em> <code>IStream</code> using <code>Save</code> method and then use <code>Bitmap::FromStream</code> to create <code>Bitmap</code> from that stream.</p> <p>A simple <em>COM</em> <code>IStream</code> could be created using the <a href="http://msdn.microsoft.com/en-us/library/aa378980.aspx" rel="nofollow noreferrer"><code>CreateStreamOnHGlobal</code></a> <em>WinAPI</em> function. However this is not efficient, especially for larger streams, but to test the idea it will do.</p> <p>There are also other similar solutions which can be deduced from reading <a href="http://msdn.microsoft.com/en-us/library/ms534462.aspx" rel="nofollow noreferrer"><code>Image</code></a> and <a href="http://msdn.microsoft.com/en-us/library/ms534420.aspx" rel="nofollow noreferrer"><code>Bitmap</code></a> documentation.</p> <p>Sadly I haven't tried it on my own (with <code>Image</code> which is not a <code>Bitmap</code>) so I am not entirely sure.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload