![]() |
|
![]() |
![]() |
![]() | Donate | ![]() |
![]() |
![]() |
Ouvrir sur le forum | Recherche | Messages du jour | Marquer les forums comme lus |
Aide au développement Aide sur l'utilisation d'OSLib |
Publicité |
![]() |
|
Outils de la discussion | Modes d'affichage |
![]() |
#1 |
Membre
Date d'inscription: 02/04/2008
Messages: 16
|
![]() Hi, I have a Problem. I want to know, if it' s possible to read the color of an spezific pixel. I mean, i have the pixel 10*10 and want to know, if he is pink ( only an example ).
Is there a function in OSl, I mean, that I' ve read something like this somewhere, but I could' t find it. If it' s not on OSL, can someone give me a way to do this job with normal SDK?? Floorball92 ps: like last time to, sorry for my bad english xD |
![]() |
![]() |
Publicité |
![]() |
#2 |
Membre
Date d'inscription: 02/04/2008
Messages: 16
|
![]() I read a bit in the documentation and found something. I was very happy and wantet direktly try it, so I' ve made this Code:
Code:
//The main library OSLib #include <oslib/oslib.h> //The callbacks PSP_MODULE_INFO("OSLib Sample", 0, 1, 1); PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); OSL_IMAGE *bg; int main() { //Initialization of the library oslInit(0); //Initialization of the graphic mode oslInitGfx(OSL_PF_8888, 0); //Initialization of the text console oslInitConsole(); bg = oslLoadImageFile("bg.png", OSL_IN_RAM, OSL_PF_5551); //Display text on the screen oslPrintf("%s", oslGetImagePixelAdr(bg,10,10)); //Wait a keystroke oslWaitKey(); //Leaving the program oslEndGfx(); oslQuit(); return 0; } What' s wrong with this?? |
![]() |
![]() |
![]() |
#3 |
Membre confirmé
|
![]() Have you tried this?
Code PHP:
If you want to know if that pixel is pink (255,0,255) just see if pixel==RGB(255,0,255) |
![]() |
![]() |
![]() |
#4 |
Membre
Date d'inscription: 02/04/2008
Messages: 16
|
![]() Do I have to insert something for pixelformat and palette ??
|
![]() |
![]() |
![]() |
#5 |
Membre confirmé
|
![]() yes, it's those of your osl_image...
Code PHP:
Again, I haven't tested, but that would be my first try. |
![]() |
![]() |
![]() |
#6 |
Membre
Date d'inscription: 02/04/2008
Messages: 16
|
![]() This works perfect, thank you so much
![]() |
![]() |
![]() |
![]() |
#7 |
Membre confirmé
|
![]() I'm glad I could help
![]() |
![]() |
![]() |
![]() |
#8 |
Membre
Date d'inscription: 02/04/2008
Messages: 16
|
![]() OK, but now I have one question on that. How can I make this in Maps, because I can' t read from the tileset, so there must be a way for me to do the same like here but with a map.
|
![]() |
![]() |
![]() |
#9 |
Membre
Date d'inscription: 30/11/2007
Messages: 29
|
![]() It would be nice to do map and collisionmap, theyre the same cord so i can do something like that
bool collision(xplus,yplus) { bool coll=false; OSL_IMAGE *theimage=oslLoadImageFile("theimage.png", OSL_IN_RAM, OSL_PF_8888); OSL_COLOR pixel=oslConvertColorEx(theimage->palette, OSL_PF_8888, theimage->pixelFormat, oslGetImagePixel(theimage, y+yplus, y+yplus)); if(pixel==RGB(255,0,255)) answer=true; return answer; } But like my friend i have no idea how to check this on map. |
![]() |
![]() |
![]() |
#10 |
Newbie
Date d'inscription: 16/07/2008
Messages: 3
|
![]() Hi all,
a workaround to get pixel color in a mask map : use of an OSL_IMAGE as a hidden buffer. consider this : Visible tileset map : mapTileSet Mask tileset map : mapTileSetMask Hidden OSL_IMAGE : OSL_IMAGE * tmpImg = oslCreateImage(RESOLUTION_ECRAN_X, RESOLUTION_ECRAN_Y, OSL_IN_VRAM, OSL_PF_5650) Pixel color : int maskPixelColor Code : oslSetDrawBuffer(tmpImg); mapTileSetMask->scrollX = mapTileSet->scrollX; mapTileSetMask->scrollY = mapTileSet->scrollY; oslDrawMap(mapTileSetMask); maskPixelColor = oslGetImagePixel(tmpImg, X_you_want, Y_you_want); oslSetDrawBuffer(OSL_DEFAULT_BUFFER); maskPixelColor containt the color of the pixel in the mask Map. Bye, Yinstyx Dernière modification par Yinstyx ; 17/08/2008 à 21h06. |
![]() |
![]() |
![]() |
#11 | |
Membre
Date d'inscription: 30/11/2007
Messages: 29
|
![]() Citation:
|
|
![]() |
![]() |
![]() |
#12 |
Super Modérateur
Date d'inscription: 10/11/2005
Localisation: Un pays avec beaucoup de banques
Messages: 3 225
|
![]() Are you sure you need to do that? The drawbuffer (= the screen) is itself an image, you can get it by oslGetDrawBuffer(). So you could read the pixel that way.
But beware that because the GPU may be drawing at the moment you read the pixel (i.e. the drawing is not finished) you may not get the right color. So, before reading anything on the screen, always ensure that the drawing is finished with a former oslSyncDrawing call ![]() |
![]() |
![]() |
![]() |
#13 | |
Membre
Date d'inscription: 30/11/2007
Messages: 29
|
![]() Citation:
|
|
![]() |
![]() |
![]() |
Liens sociaux |
Publicité |
Utilisateurs regardant la discussion actuelle : 1 (0 membre(s) et 1 invité(s)) | |
Outils de la discussion | |
Modes d'affichage | |
|
|