ndless get_pixel
Posté: 31 Mai 2020, 08:04
Is it possible to get the color of a pixel using ndless? I can only see writing functions in ngc.h
News, programmes, tutoriaux, forum sur les calculatrices TI !
https://tiplanet.org/forum/
int os_get_pixel(int x,int y){
unsigned short * addr=(unsigned short *) 0xC0000010;
int r=addr[y*SCREEN_WIDTH+x];
return r;
}
Gc nspire_gc=0;
Gc * get_gc(){
if (!nspire_gc){
nspire_gc=gui_gc_global_GC();
gui_gc_setRegion(nspire_gc, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
gui_gc_begin(nspire_gc);
}
return &nspire_gc;
}
int os_get_pixel(int x,int y){
if (x<0 || x>=SCREEN_WIDTH || y<0 || y>=SCREEN_HEIGHT)
return -1;
get_gc();
char ** off_buff = ((((char *****)nspire_gc)[9])[0])[0x8];
int res = *(unsigned short *) (off_buff[y+nspire_statusarea] + 2*x);
return res;
}
parisse a écrit:I tried
- Code: Tout sélectionner
int os_get_pixel(int x,int y){
unsigned short * addr=(unsigned short *) 0xC0000010;
int r=addr[y*SCREEN_WIDTH+x];
return r;
}
But that does not work (tried on a nspire cx). I filled a rectangle (0,0,100,100) with red, then get_pixel(2,30) does not return the same value as get_pixel(2,31), 27113 then 0.
int os_get_pixel(int x,int y){
unsigned short * addr=*(unsigned short **) 0xC0000010;
int r=addr[y*SCREEN_WIDTH+x];
return r;
}