Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / as I know the color of a pixel?

Author
Message
pamercomov
FPSC Reloaded TGC Backer
9
Years of Service
User Offline
Joined: 2nd Jan 2015
Location: palma de mallorca
Posted: 27th Dec 2015 06:58
hi.
I wanted to know how I can know the color of a particular pixel of an image or sprite in a particular x and y position.

I'm trying to map different colors and hardnesses not get the color pixel collision.

thank you
using AppGameKit V2 tier 1
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 27th Dec 2015 08:05
I don't think there is a command that does this.

You could put the image in a memblock, and check the color of a pixel in the memblock.

From the help for CreateMemblockFromImage()



You could calculate which pixel to check, or an easier way might be to just grab a 1x1 image of the pixel you need to check. That would give the color as the last 4 bytes of the memblock.
Timshark
17
Years of Service
User Offline
Joined: 30th Jun 2007
Location: Oslo, Norway
Posted: 27th Dec 2015 11:45
This is something I added to the snippets thread
it returns the color as a string (rgb$)

pamercomov
FPSC Reloaded TGC Backer
9
Years of Service
User Offline
Joined: 2nd Jan 2015
Location: palma de mallorca
Posted: 27th Dec 2015 12:00
very very very thanx .

using AppGameKit V2 tier 1
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Dec 2015 11:12
Nice solution TimShark, is it fast enough to use interactively, or should it be used carefully? I have never tried getImage with 1 pixel.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 29th Dec 2015 02:12
This is the way to go but although CreateMemblockfromImage is okay on the PC or MAC, it is not ideal on mobile devices as it is a slow command to be repeated constantly.
The Amiga and Amos were great!
My website LEAP - Download Paint Pot here!

Login to post a reply

Server time is: 2024-09-29 09:25:40
Your offset time is: 2024-09-29 09:25:40