<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Windows CE Graphics</title><subtitle type="html" /><id>http://blogs.msdn.com/jsirois/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/jsirois/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/jsirois/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2003-12-30T13:28:00Z</updated><entry><title>Using GetObject to find out the pixel format of a bitmap.</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/jsirois/archive/2004/04/25/119997.aspx" /><id>http://blogs.msdn.com/jsirois/archive/2004/04/25/119997.aspx</id><published>2004-04-26T00:47:00Z</published><updated>2004-04-26T00:47:00Z</updated><content type="html">&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;</content><author><name>jsirois</name><uri>http://blogs.msdn.com/members/jsirois.aspx</uri></author><category term="WinCE" scheme="http://blogs.msdn.com/jsirois/archive/tags/WinCE/default.aspx" /><category term="CE vs. XP" scheme="http://blogs.msdn.com/jsirois/archive/tags/CE+vs.+XP/default.aspx" /></entry><entry><title>When WinMain just isn't the same...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/jsirois/archive/2004/01/21/61447.aspx" /><id>http://blogs.msdn.com/jsirois/archive/2004/01/21/61447.aspx</id><published>2004-01-22T04:12:00Z</published><updated>2004-01-22T04:12:00Z</updated><content type="html">&lt;P&gt;If I'm going to ever talk about writing code on Windows CE, I'll need to get started. Probably the most obvious place to start is &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/WinMain.asp"&gt;WinMain&lt;/A&gt;. Wait, that's the desktop's version of WinMain, since I'm writing code on Windows CE, I'll want to look at the Windows CE version of &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceui40/html/cerefwinmain.asp"&gt;WinMain&lt;/A&gt;. Why would CE have a different prototype for WinMain than XP? Well the answer to that is simple: Windows CE uses UNICODE.&amp;nbsp;Most (maybe all?)&amp;nbsp;of the Win32 functions that have ASCII or wide chacarcter variants on XP, only have the wide character variant on CE. This cuts down on the number of entries in coredll, and helps to promote writing international-safe apps.&lt;/P&gt;
&lt;P&gt;The prototype for XP's version of WinMain is:&lt;/P&gt;
&lt;P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;&lt;B&gt;int&lt;/B&gt; &lt;B&gt;WINAPI&lt;/B&gt; &lt;B&gt;WinMain(&lt;/B&gt;
  &lt;B&gt;HINSTANCE&lt;/B&gt; &lt;I&gt;hInstance&lt;/I&gt;&lt;B&gt;, &lt;/B&gt;
  &lt;B&gt;HINSTANCE&lt;/B&gt; &lt;I&gt;hPrevInstance&lt;/I&gt;&lt;B&gt;, &lt;/B&gt;
  &lt;B&gt;LPSTR&lt;/B&gt; &lt;I&gt;lpCmdLine&lt;/I&gt;&lt;B&gt;, &lt;/B&gt;
  &lt;B&gt;int&lt;/B&gt; &lt;I&gt;nShowCmd &lt;/I&gt;
&lt;B&gt;);&lt;/B&gt; &lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The prototype for CE's version of WinMain is:&lt;/P&gt;
&lt;P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE&gt;&lt;B&gt;int&lt;/B&gt; &lt;B&gt;WINAPI&lt;/B&gt; &lt;B&gt;WinMain(&lt;/B&gt;
  &lt;B&gt;HINSTANCE&lt;/B&gt; &lt;I&gt;hInstance&lt;/I&gt;&lt;B&gt;, &lt;/B&gt;
  &lt;B&gt;HINSTANCE&lt;/B&gt; &lt;I&gt;hPrevInstance&lt;/I&gt;&lt;B&gt;, &lt;/B&gt;
  &lt;B&gt;LPWSTR&lt;/B&gt; &lt;I&gt;lpCmdLine&lt;/I&gt;&lt;B&gt;, &lt;/B&gt;
  &lt;B&gt;int&lt;/B&gt; &lt;I&gt;nShowCmd &lt;/I&gt;
&lt;B&gt;);&lt;/B&gt; &lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The only difference is with the &lt;EM&gt;lpCmdLine&lt;/EM&gt; parameter. On CE it's always of type &lt;STRONG&gt;LPWSTR&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Well, that's the first difference I wanted to point out. It's probably obvious to most people, but I think it's a decent place to start.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=61447" width="1" height="1"&gt;</content><author><name>jsirois</name><uri>http://blogs.msdn.com/members/jsirois.aspx</uri></author><category term="code" scheme="http://blogs.msdn.com/jsirois/archive/tags/code/default.aspx" /><category term="CE vs. XP" scheme="http://blogs.msdn.com/jsirois/archive/tags/CE+vs.+XP/default.aspx" /></entry><entry><title>Welcome...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/jsirois/archive/2003/12/30/46739.aspx" /><id>http://blogs.msdn.com/jsirois/archive/2003/12/30/46739.aspx</id><published>2003-12-30T21:28:00Z</published><updated>2003-12-30T21:28:00Z</updated><content type="html">&lt;P&gt;&lt;FONT face="Courier New"&gt;Welcome to the new home for my sporadically updated blog. I'm particularly fond of fixed width fonts, so you'll probably be seeing a lot of them.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;Over the next couple of days, I'll be playing around with the formatting of this site (and probably posting a bunch of &amp;#8220;test&amp;#8221; messages to see how things look or work.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=46739" width="1" height="1"&gt;</content><author><name>jsirois</name><uri>http://blogs.msdn.com/members/jsirois.aspx</uri></author><category term="random" scheme="http://blogs.msdn.com/jsirois/archive/tags/random/default.aspx" /></entry></feed>