#include "oslib/oslib.h"


void Getpixel()
{

	OSL_IMAGE *img;

	img = oslLoadImageFile("media/splash.png", OSL_IN_RAM, OSL_PF_8888);

	int possX = 1;
	int possY = 1;


	while (!osl_quit)
	{
		oslStartDrawing();
		oslReadKeys();

		oslDrawImage(img);


		if (osl_keys->held.up){
			possY -= 3;
		}

		if (osl_keys->held.down){
			possY +=3;
		}

		if (osl_keys->held.right){
			possX +=3;
		}
	
		if (osl_keys->held.left){
			possX -=3;
		}

		//definit les couleur du texte
		oslSetTextColor(RGBA(255,255,255,255));
		oslSetBkColor(RGBA(0,0,0,255));

		//la fonction getpixel pour recuperer les info
		int ptr = oslGetImagePixel(img, possX, possY);

		u8 red, green, blue, alpha;
		//convertir c'est infor en R V B
		oslRgbaGet8888((unsigned int)ptr, red, green, blue, alpha);
		//Affichage de l'information
		oslPrintf_xy(0, 10,"R %i V %i B %i A %i", red, green, blue, alpha);
		//oslPrintf_xy(0, 30, "%d",  (unsigned int )ptr);

		//curseur ici
		oslDrawLine(possX, possY, possX+5, possY+5, RGBA(255, 0, 0, 255));

		//dessine ici la couleur choisi
		oslDrawFillRect(10, 200, 200, 272, RGBA(red, green, blue, alpha));


		oslSynchronization();

		if (osl_keys->pressed.start)break;

	}


}


