<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Windows CE Graphics : WinCE</title><link>http://blogs.msdn.com/jsirois/archive/tags/WinCE/default.aspx</link><description>Tags: WinCE</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using GetObject to find out the pixel format of a bitmap.</title><link>http://blogs.msdn.com/jsirois/archive/2004/04/25/119997.aspx</link><pubDate>Mon, 26 Apr 2004 00:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:119997</guid><dc:creator>jsirois</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jsirois/comments/119997.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jsirois/commentrss.aspx?PostID=119997</wfw:commentRss><description>&lt;P&gt;GDI has a method call &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefgetobject.asp"&gt;GetObject&lt;/A&gt; which can be used to get information about a GDI object. On Windows CE you can use GetObject to get the pixel format for any bitmap by passing in a &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefdibsection.asp"&gt;DIBSECTION&lt;/A&gt; instead of a &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefbitmap.asp"&gt;BITMAP&lt;/A&gt;. Here's an example:&lt;/P&gt;
&lt;P&gt;&lt;PRE&gt;   DIBSECTION ds;
   HDC        hdc = GetDC(NULL);
   HGDIOBJ    bmp = GetCurrentObject(hdc, OBJ_BITMAP);

   GetObject(bmp, sizeof (ds), &amp;amp;ds);
&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Obviously, in production code you'd want to actually check return values, but this is the general idea. If (ds.dsBm.bmBitsPixel &amp;gt; 8) and (ds.dsBmih.biCompression == BI_BITFILEDS), ds.dsBitfields will&amp;nbsp;contain the bit&amp;nbsp;masks for the three color channels. If ds.dsBmih.biCompression is BI_RGB, the bitmap is either an RGB surface, or a palettized surface and ds.dsBitfields will be 0.&lt;/P&gt;
&lt;P&gt;This behavior makes it relatively easy to create a DIB section that has the same pixel format as another bitmap.&lt;/P&gt;
&lt;P&gt;FYI: I don't believe this works on the desktop.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=119997" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jsirois/archive/tags/WinCE/default.aspx">WinCE</category><category domain="http://blogs.msdn.com/jsirois/archive/tags/CE+vs.+XP/default.aspx">CE vs. XP</category></item></channel></rss>