Isometric mouse mapping problem

Hello there.

I was writing something like isometric tile engine and had the famous problem: mouse mapping =).
Well i do it by comparing the colors of the mouse tile ( you know, this isometric diamond with read yellow green and blue corners)
But there is a problem. Maybe its some getting pixel error, i dont know.
Here is the code:


    int x, y;
point offset;
Uint8 r, g, b;
Uint16 *raw_pixel;
Uint32 pixel;
int of;

x = Cursor.x / TILE_WIDTH;
y = Cursor.y / TILE_HEIGHT;

offset.x = Cursor.x - (x * TILE_WIDTH);
offset.y = Cursor.y - (y * TILE_HEIGHT);


raw_pixel = (Uint16 *) mousemap->pixels;
of = mousemap->pitch / 2 * offset.y + offset.x;

pixel = raw_pixel[of];

SDL_GetRGB(pixel, mousemap->format, &r, &g, &b);



Its not the complete code, but error is somewhere here. It doesnt get the right color.

Thanks for any help.