HI,

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:

Uint32 getpixel(SDL_Surface *surface, int x, int y)
{
    int bpp = surface->format->BytesPerPixel;
    /* Here p is the address to the pixel we want to retrieve */
    Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;

    switch(bpp) {
    case 1:
        return *p;

    case 2:
        return *(Uint16 *)p;

    case 3:
        if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
            return p[0] << 16 | p[1] << 8 | p[2];
        else
            return p[0] | p[1] << 8 | p[2] << 16;

    case 4:
        return *(Uint32 *)p;

    default:
        return 0;       /* shouldn't happen, but avoids warnings */
    }


}

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.

Any idea why?



On Mon, Feb 12, 2007 at 11:35 AM, Tapani Pälli <[EMAIL PROTECTED]>
wrote:

> ext Michael Stepanov wrote:
> > Thanks for your answer, Tarani.
> >
> > On 2/12/07, *Tapani Pälli* <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> >     ext Michael Stepanov wrote:
> >     > Well, there is a open source system for home automation -
> Plutohome
> >     > (www.plutohome.com <http://www.plutohome.com>
> >     <http://www.plutohome.com <http://www.plutohome.com>>). This
> >     system can use
> >     > Nokia770/800 as a control panel - Orbiter. The Orbiter is based on
> >     > SDL. So, after some hack it started work on Nokia
> >     (os2005/os2006) but
> >     > there is a problem. Icons on the Orbiter should change their color
> >     > according to some events.
> >
> >     Are you missing icon 'highlight' effect when mouse is moved on top
> of
> >     icon? Please specify exactly what the 'some events' are.
> >
> >
> > The color of icon should be changed according to status of real device
> > which represented by this icon. For example, there is a lighting
> > switch and its icon. If switch is ON icon should be yellow, otherwise
> > it should be black. But in real device icon every time is pink. I
> > suspect that something wrong with pixels coloring using SDL. There is
> > a method
> Ah ok, pink might be colorkey for 1-bit transparency and shouldn't be
> displayed.
>
> > OrbiterRenderer_SDL::ReplaceColorInRectangle in the
> > OrbiterRenderer_SDL.cpp which changes colors of icons. Maybe SDL for
> > nokia 770 uses different color format for pixels?
> >
> Yep, you could try a simple hack to find out wheter bug is here by
> replacing putpixel call in loop to paint only red :
> SDLGraphic::putpixel(m_pScreenImage,i + x, j + y, SDL_MapRGB(PF, 255, 0,
> 0); ... it seems algorithm is checking wheter destination color differs
> from source enough and if so it paints. However I don't see anything
> wrong in getpixel or putpixel, they should OK.
>
> >     > Initially they are pink. Using SDL functionality their color can
> be
> >     > changed. It works fine for Debian but it didn't work for Nokia
> >     (either
> >     > scratchbox emulator or real device). All icons are pink every
> time.
> >     > I'm not developer. I'm integrator. So, it's difficult for me to
> >     > understand where is the problem. Have a look attached files.
> >     Maybe you
> >     > can help me.
> >     >
> >
> >     I couldn't spot bugs in the code you sent, maybe OrbiterLogic has
> some
> >     calls to renderer to change icon colors?. One thing which should be
> >     changed in renderer class is the colordepth used for surfaces.
> >     Right now
> >     it seems to be hardcoded to certain places as 32. Code should read
> the
> >     correct depth using SDL_GetVideoInfo and make sure all the newly
> >     created
> >     surfaces use the same depth to avoid amount of needed conversions.
> >
> >
> > Thanks, I check it.
> >
> >     > Thanks in advanced.
> >     >
> >     > On 2/9/07, * [EMAIL PROTECTED]
> >     <mailto:[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]
> >     <mailto:[EMAIL PROTECTED]>>*
> >     > <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> >     <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>>
> >     wrote:
> >     >
> >     >     Hello,
> >     >     Could you be more specific what are you trying todo and how?
> >     Are you
> >     >     going through pixelvalues and accessing them? See
> >     >     surface->format->BytesPerPixel. SDL_GetRGB and SDL_MapRGB
> >     should work
> >     >     allright.
> >     >
> >     >     // Tapani
> >     >
> >     >
> >
> >     --- 8< -----
> >
> >     // T
> >
> >
> >
> >
> > --
> > Cheers,
> > Michael
>
> // Tapani
>
>


-- 
Cheers,
Michael
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers

Reply via email to