HI,<br><br>Long time ago I tried to investigated the problem of replacing pixel'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->format->BytesPerPixel;<br> /* Here p is the address to the pixel we want to retrieve */<br> Uint8 *p = (Uint8 *)surface->pixels + y * surface->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] << 16 | p[1] << 8 | p[2];<br> else<br>
return p[0] | p[1] << 8 | p[2] << 16;<br><br> case 4:<br> return *(Uint32 *)p;<br><br> default:<br> return 0; /* shouldn'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 <<a href="mailto:tapani.palli@nokia.com">tapani.palli@nokia.com</a>> 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>
> Thanks for your answer, Tarani.<br>
><br>
> On 2/12/07, *Tapani Pälli* <<a href="mailto:tapani.palli@nokia.com">tapani.palli@nokia.com</a><br>
</div><div class="Ih2E3d">> <mailto:<a href="mailto:tapani.palli@nokia.com">tapani.palli@nokia.com</a>>> wrote:<br>
><br>
> ext Michael Stepanov wrote:<br>
> > Well, there is a open source system for home automation - Plutohome<br>
> > (<a href="http://www.plutohome.com" target="_blank">www.plutohome.com</a> <<a href="http://www.plutohome.com" target="_blank">http://www.plutohome.com</a>><br>
</div>> <<a href="http://www.plutohome.com" target="_blank">http://www.plutohome.com</a> <<a href="http://www.plutohome.com" target="_blank">http://www.plutohome.com</a>>>). This<br>
<div class="Ih2E3d">> system can use<br>
> > Nokia770/800 as a control panel - Orbiter. The Orbiter is based on<br>
> > SDL. So, after some hack it started work on Nokia<br>
> (os2005/os2006) but<br>
> > there is a problem. Icons on the Orbiter should change their color<br>
> > according to some events.<br>
><br>
> Are you missing icon 'highlight' effect when mouse is moved on top of<br>
> icon? Please specify exactly what the 'some events' are.<br>
><br>
><br>
> The color of icon should be changed according to status of real device<br>
> which represented by this icon. For example, there is a lighting<br>
> switch and its icon. If switch is ON icon should be yellow, otherwise<br>
> it should be black. But in real device icon every time is pink. I<br>
> suspect that something wrong with pixels coloring using SDL. There is<br>
> a method<br>
</div>Ah ok, pink might be colorkey for 1-bit transparency and shouldn't be<br>
displayed.<br>
<div class="Ih2E3d"><br>
> OrbiterRenderer_SDL::ReplaceColorInRectangle in the<br>
> OrbiterRenderer_SDL.cpp which changes colors of icons. Maybe SDL for<br>
> nokia 770 uses different color format for pixels?<br>
><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't see anything<br>
wrong in getpixel or putpixel, they should OK.<br>
<div class="Ih2E3d"><br>
> > Initially they are pink. Using SDL functionality their color can be<br>
> > changed. It works fine for Debian but it didn't work for Nokia<br>
> (either<br>
> > scratchbox emulator or real device). All icons are pink every time.<br>
> > I'm not developer. I'm integrator. So, it's difficult for me to<br>
> > understand where is the problem. Have a look attached files.<br>
> Maybe you<br>
> > can help me.<br>
> ><br>
><br>
> I couldn't spot bugs in the code you sent, maybe OrbiterLogic has some<br>
> calls to renderer to change icon colors?. One thing which should be<br>
> changed in renderer class is the colordepth used for surfaces.<br>
> Right now<br>
> it seems to be hardcoded to certain places as 32. Code should read the<br>
> correct depth using SDL_GetVideoInfo and make sure all the newly<br>
> created<br>
> surfaces use the same depth to avoid amount of needed conversions.<br>
><br>
><br>
> Thanks, I check it.<br>
><br>
> > Thanks in advanced.<br>
> ><br>
> > On 2/9/07, * <a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a><br>
</div>> <mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>> <mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a><br>
<div class="Ih2E3d">> <mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>>>*<br>
> > <<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a> <mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>><br>
</div>> <mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a> <mailto:<a href="mailto:Tapani.Palli@nokia.com">Tapani.Palli@nokia.com</a>>>><br>
<div><div></div><div class="Wj3C7c">> wrote:<br>
> ><br>
> > Hello,<br>
> > Could you be more specific what are you trying todo and how?<br>
> Are you<br>
> > going through pixelvalues and accessing them? See<br>
> > surface->format->BytesPerPixel. SDL_GetRGB and SDL_MapRGB<br>
> should work<br>
> > allright.<br>
> ><br>
> > // Tapani<br>
> ><br>
> ><br>
><br>
> --- 8< -----<br>
><br>
> // T<br>
><br>
><br>
><br>
><br>
> --<br>
> Cheers,<br>
> Michael<br>
<br>
</div></div><font color="#888888">// Tapani<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br>Michael