HP Forums
HP Prime - GETPIX_P Return? - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: HP Prime - GETPIX_P Return? (/thread-256853.html)



HP Prime - GETPIX_P Return? - Thomas Chrapkiewicz - 11-24-2013

Any experience with the data returned from the GETPIX_P(x,y,)function?

When I execute:

PIXON_P(160,120,#0000FF);
PRINT B->R(GETPIX_P(160,120));

prints 248 - that is the return value always seems 'off' by about 7 (3 bits low?).

Is there a datatype/bitwidth conversion I am missing?

Thanks,

TomC


Re: HP Prime - GETPIX_P Return? - Patrice - 11-24-2013

The color coding is the one of html.

Only 5 bits in each chanel are used. Thus the 3 lower bits in each chanel stay to 0.

EXPORT SHOW_CLR()
BEGIN
LOCAL cr, cg, cb, clr, pc, pl;
RECT();
FOR cr FROM 0 TO 31 DO
pl:= cr MOD 8* 34;
pc:= IP(cr/8)* 34;
FOR cg FROM 0 TO 31 DO
FOR cb FROM 0 TO 31 DO
clr:= RGB(cr*8,cg*8,cb*8);
PIXON_P(cb+pl+2,cg+pc+2,clr);
END;
END;
END;

REPEAT
UNTIL GETKEY() == -1;
FREEZE;
END;




Re: HP Prime - GETPIX_P Return? - Thomas Chrapkiewicz - 11-24-2013

Thank you Patrice! Very nice code!

TomC


Re: HP Prime - GETPIX_P Return? - Thomas Chrapkiewicz - 11-24-2013

Along these lines, what I'm after, is to read a pixel, and return the amount of R, G and B in that pixel. It seems I need to read the pixel, mask the appropriate bits and then ignore the lower three bits.

Has anyone developed code for this?

thanks,

TomC


Re: HP Prime - GETPIX_P Return? - Damien - 11-24-2013

This thread, on omnimaga forum, may interest you:
http://www.omnimaga.org/index.php?topic=16870.0

Regards

Damien.

Edited: 24 Nov 2013, 6:22 p.m.


Re: HP Prime - GETPIX_P Return? - cyrille de Brébisson - 11-25-2013

Hello,

internally, colors are codded in 16 bits using ARGB 1555 format.
so, if you do:
A:= getpix_p(x,y);
return { bitand(A,#FF0000) / # 10000, bitand(A,#FF00) / # 100, bitand(A,#FF) };

you should get what you want.


Re: HP Prime - GETPIX_P Return? - Thomas Chrapkiewicz - 11-25-2013

Cyrille:

Thank you! That explains it - I wasn't certain what that leading most significant bit was!

Regards,

TomC


Re: HP Prime - GETPIX_P Return? - Thomas Chrapkiewicz - 11-25-2013

Damien:

Thanks!

TomC