<div dir="ltr">Found the problem. It&#39;s Big/Little Endian issue. It seems that SDL pixel format doesn&#39;t take into account the byte order for <b><strong style="font-weight: normal;">[RGBA]shift:<br><br>SDL_PixelFormat * PF = screen-&gt;format;<br>
<br>How can I modify the statement:<br><br></strong></b>PixelSrc = (ColorToReplace.R() &lt;&lt; PF-&gt;Rshift) |
(ColorToReplace.G() &lt;&lt; PF-&gt;Gshift) | (ColorToReplace.B()
&lt;&lt; PF-&gt;Bshift);<br><br>To use correct shift for little endian?<br><br><div class="gmail_quote">On Fri, Aug 29, 2008 at 10:44 AM, Michael Stepanov <span dir="ltr">&lt;<a href="mailto:michael@stepanoff.org">michael@stepanoff.org</a>&gt;</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 dir="ltr">Thanks a lot, guys, for your help. Finally I managed to get correct RGB from the 16bit pixel using SDL_GetRGB. First I get a pixel and then retrieve RGB from it:<br>
&nbsp; <br>&nbsp;&nbsp; Uint8 red, green, blue;<br>&nbsp;&nbsp; Uint32 pixel;<br>
<br>&nbsp;&nbsp; for(int y = 0; y &lt; 480; y++) <br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int x = 0; x &lt; 640; x++) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pixel = getpixel(surface, x, y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SDL_GetRGB((Uint32)pixel, surface-&gt;format, &amp;red, &amp;green, &amp;blue);<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br clear="all">&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp; But now I have another problem. There is a transformation of color:<br><br>&nbsp;&nbsp; PixelSrc = (ColorToReplace.R() &lt;&lt; PF-&gt;Rshift) | (ColorToReplace.G() &lt;&lt; PF-&gt;Gshift) | (ColorToReplace.B() &lt;&lt; PF-&gt;Bshift);<br>

<br>Where ColorToReplace is (255,102,155)<br><br>But after that transformation it becomes (255, 252, 7). Could somebody tell me where is a mistake?<br><br>TIA<br><br>P. S. Sorry for not clever questions. I don&#39;t have a big C++ and SDL practice.<br>

&nbsp;<br>-- <br>Cheers,<br>Michael<br>
</div>
</blockquote></div><br><br clear="all"><br>-- <br>Cheers,<br>Michael<br>
</div>