Message-ID: From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: allegro getpixel()-problem! Date: Tue, 28 Apr 1998 15:18:11 +0100 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk Bengt Rosenberger writes: > I want to use a button (it's a bitmap(125x75)) in the middle of the > screen. Now I blit a black/white-bitmap of that button directly > behind the originally one. When the button is pressed with left > mouse button I try to check if the color behind is white. I use: > > col = getpixel(buttonbw, mouse_x, mouse_y); > if (col = 255) > button_pressed(); > > When the button is pressed in the middle of the screen, the return > col is -1. This return value should give you a clue what the problem is. From the Allegro getpixel() docs: Returns -1 if the point lies outside the bitmap. The mouse coordinates are an absolute screen position, but from your description, it sounds like your buttonbw image is being plotted to some offset into the screen, not the top left corner. This means that you can't use these screen-space coordinates as a direct offset into the buttonbw bitmap: you will have to adjust them first to reflect whatever offset you are drawing this image at. Shawn Hargreaves.