<div dir="ltr"><br><br><div class="gmail_quote">On Mon, Sep 1, 2008 at 4:16 PM, Frantisek Dufka <span dir="ltr"><<a href="mailto:dufkaf@seznam.cz">dufkaf@seznam.cz</a>></span> 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">Michael Stepanov wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I have a SDL application where I have to replace color of specified pixels. So, I have a color in RGB representation and convert it to the pixel color using that approach:<br>
<br>
Uint32 PixelSrc = (0 << PF->Rshift) | (128 << PF->Gshift) | (192 << PF->Bshift);<br>
<br>
But as result I get color 0x10c0 instead of 0x0080C0. Why it's happens? <br>
</blockquote>
<br></div>
You did not mention pixel format, if you use device native 16 bit format (RGB565?) you cannot use values like 128 or 192 since it will overflow 5 or 6 bits. Also you should do proper masking.<br>
<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">
Moreover, I found following values for Xshift for little endian:<br>
<br>
const int rshift = 0, gshift = 8, bshift = 16, ashift = 24;<br></div><div class="Ih2E3d">
Uini32 PixelDest = (0 << rshift) | (128 << gshift) | (192 << bshift);<br>
<br>
But the byte order is different. I get 0xc08000 but it should be 0x0080c0.<br>
</div></blockquote>
<br>
00c08000 seems fine to me for 0<<0 | 0x80<<8 |0xC0<<16.<br>
<br>
I think you should add a bit more of your example code and also tell us what you want to do (and maybe even why).</blockquote><div><br>Ok, there is an SDL application which was ported from x86 to Nokia. The issue with color is following. The application finds some icons on the picture (they are all pink - 255, 102, 255) and replace them by proper color - yellow, red, gray etc. The replacement colors are 32bit but Nokia uses 16bit as you already mentioned. So, I found the way how to compare pink color with actual color of specified pixel:<br>
<br>SDL_GetRGB((Uint32)Pixel, m_pScreenImage->format, &red, &green, &blue);<br><br>where Pixel is retrieved from the surface in the loop.<br><br>But now I have to fill pink pixel by specified color. And as I understand I should convert that color from 32bit to 16bit? How can I do it?<br>
<br>Maybe that's why Xshift works wrongly because I try to use 32bit color definition with 16bit surface?<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><font color="#888888">
<br>
Frantisek<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br>Michael<br>
</div>