HI,<br><br>Long time ago I tried to investigated the problem of replacing pixel&#39;s colors. So, I faced with that problem again. But the problem is in the result of getpixel() method. I use the similar one:<br><pre>Uint32 getpixel(SDL_Surface *surface, int x, int y)<br>
{<br>    int bpp = surface-&gt;format-&gt;BytesPerPixel;<br>    /* Here p is the address to the pixel we want to retrieve */<br>    Uint8 *p = (Uint8 *)surface-&gt;pixels + y * surface-&gt;pitch + x * bpp;<br><br>    switch(bpp) {<br>
    case 1:<br>        return *p;<br><br>    case 2:<br>        return *(Uint16 *)p;<br><br>    case 3:<br>        if(SDL_BYTEORDER == SDL_BIG_ENDIAN)<br>            return p[0] &lt;&lt; 16 | p[1] &lt;&lt; 8 | p[2];<br>        else<br>
            return p[0] | p[1] &lt;&lt; 8 | p[2] &lt;&lt; 16;<br><br>    case 4:<br>        return *(Uint32 *)p;<br><br>    default:<br>        return 0;       /* shouldn&#39;t happen, but avoids warnings */<br>    }<br><br>
<span style="font-family: arial,sans-serif;"></span><br>}</pre>In case of Nokia that method returns *(Uint16 *)p. But instead of 6 hexadecimals it returns only 4. For example, for white color it returns FFFF instead of FFFFF. The same, for the rest of colors.<br>
<br>Any idea why?<br><pre><br></pre>
<br><div class="gmail_quote">On Mon, Feb 12, 2007 at 11:35 AM, Tapani Pälli &lt;<a href="mailto:tapani.palli@nokia.com">tapani.palli@nokia.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">ext Michael Stepanov wrote:<br>
&gt; Thanks for your answer, Tarani.<br>
&gt;<br>
&gt; On 2/12/07, *Tapani Pälli* &lt;<a href="mailto:tapani.palli@nokia.com">tapani.palli@nokia.com</a><br>
</div><div class="Ih2E3d">&gt; &lt;mailto:<a href="mailto:tapani.palli@nokia.com">tapani.palli@nokia.com</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt; &nbsp; &nbsp; ext Michael Stepanov wrote:<br>
&gt; &nbsp; &nbsp; &gt; Well, there is a open source system for home automation - Plutohome<br>
&gt; &nbsp; &nbsp; &gt; (<a href="http://www.plutohome.com" target="_blank">www.plutohome.com</a> &lt;<a href="http://www.plutohome.com" target="_blank">http://www.plutohome.com</a>&gt;<br>
</div>&gt; &nbsp; &nbsp; &lt;<a href="http://www.plutohome.com" target="_blank">http://www.plutohome.com</a> &lt;<a href="http://www.plutohome.com" target="_blank">http://www.plutohome.com</a>&gt;&gt;). This<br>
<div class="Ih2E3d">&gt; &nbsp; &nbsp; system can use<br>
&gt; &nbsp; &nbsp; &gt; Nokia770/800 as a control panel - Orbiter. The Orbiter is based on<br>
&gt; &nbsp; &nbsp; &gt; SDL. So, after some hack it started work on Nokia<br>
&gt; &nbsp; &nbsp; (os2005/os2006) but<br>
&gt; &nbsp; &nbsp; &gt; there is a problem. Icons on the Orbiter should change their color<br>
&gt; &nbsp; &nbsp; &gt; according to some events.<br>
&gt;<br>
&gt; &nbsp; &nbsp; Are you missing icon &#39;highlight&#39; effect when mouse is moved on top of<br>
&gt; &nbsp; &nbsp; icon? Please specify exactly what the &#39;some events&#39; are.<br>
&gt;<br>
&gt;<br>
&gt; The color of icon should be changed according to status of real device<br>
&gt; which represented by this icon. For example, there is a lighting<br>
&gt; switch and its icon. If switch is ON icon should be yellow, otherwise<br>
&gt; it should be black. But in real device icon every time is pink. I<br>
&gt; suspect that something wrong with pixels coloring using SDL. There is<br>
&gt; a method<br>
</div>Ah ok, pink might be colorkey for 1-bit transparency and shouldn&#39;t be<br>
displayed.<br>
<div class="Ih2E3d"><br>
&gt; OrbiterRenderer_SDL::ReplaceColorInRectangle in the<br>
&gt; OrbiterRenderer_SDL.cpp which changes colors of icons. Maybe SDL for<br>
&gt; nokia 770 uses different color format for pixels?<br>
&gt;<br>
</div>Yep, you could try a simple hack to find out wheter bug is here by<br>
replacing putpixel call in loop to paint only red :<br>
SDLGraphic::putpixel(m_pScreenImage,i + x, j + y, SDL_MapRGB(PF, 255, 0,<br>
0); ... it seems algorithm is checking wheter destination color differs<br>
from source enough and if so it paints. However I don&#39;t see anything<br>
wrong in getpixel or putpixel, they should OK.<br>
<div class="Ih2E3d"><br>
&gt; &nbsp; &nbsp; &gt; Initially they are pink. Using SDL functionality their color can be<br>
&gt; &nbsp; &nbsp; &gt; changed. It works fine for Debian but it didn&#39;t work for Nokia<br>
&gt; &nbsp; &nbsp; (either<br>
&gt; &nbsp; &nbsp; &gt; scratchbox emulator or real device). All icons are pink every time.<br>
&gt; &nbsp; &nbsp; &gt; I&#39;m not developer. I&#39;m integrator. So, it&#39;s difficult for me to<br>
&gt; &nbsp; &nbsp; &gt; understand where is the problem. Have a look attached files.<br>
&gt; &nbsp; &nbsp; Maybe you<br>
&gt; &nbsp; &nbsp; &gt; can help me.<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; I couldn&#39;t spot bugs in the code you sent, maybe OrbiterLogic has some<br>
&gt; &nbsp; &nbsp; calls to renderer to change icon colors?. One thing which should be<br>
&gt; &nbsp; &nbsp; changed in renderer class is the colordepth used for surfaces.<br>
&gt; &nbsp; &nbsp; Right now<br>
&gt; &nbsp; &nbsp; it seems to be hardcoded to certain places as 32. Code should read the<br>
&gt; &nbsp; &nbsp; correct depth using SDL_GetVideoInfo and make sure all the newly<br>
&gt; &nbsp; &nbsp; created<br>
&gt; &nbsp; &nbsp; surfaces use the same depth to avoid amount of needed conversions.<br>
&gt;<br>
&gt;<br>
&gt; Thanks, I check it.<br>
&gt;<br>
&gt; &nbsp; &nbsp; &gt; Thanks in advanced.<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; On 2/9/07, * <a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a><br>
</div>&gt; &nbsp; &nbsp; &lt;mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>&gt; &lt;mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a><br>
<div class="Ih2E3d">&gt; &nbsp; &nbsp; &lt;mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>&gt;&gt;*<br>
&gt; &nbsp; &nbsp; &gt; &lt;<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a> &lt;mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>&gt;<br>
</div>&gt; &nbsp; &nbsp; &lt;mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a> &lt;mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>&gt;&gt;&gt;<br>
<div><div></div><div class="Wj3C7c">&gt; &nbsp; &nbsp; wrote:<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Hello,<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Could you be more specific what are you trying todo and how?<br>
&gt; &nbsp; &nbsp; Are you<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; going through pixelvalues and accessing them? See<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; surface-&gt;format-&gt;BytesPerPixel. SDL_GetRGB and SDL_MapRGB<br>
&gt; &nbsp; &nbsp; should work<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; allright.<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; // Tapani<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; --- 8&lt; -----<br>
&gt;<br>
&gt; &nbsp; &nbsp; // T<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Cheers,<br>
&gt; Michael<br>
<br>
</div></div><font color="#888888">// Tapani<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br>Michael