HP Prime - GETPIX_P Return?



#3

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


#4

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;


#5

Thank you Patrice! Very nice code!

TomC

#6

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


#7

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.


#8

Damien:

Thanks!

TomC

#9

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.


#10

Cyrille:

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

Regards,

TomC


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP PRIME: Hide return value from program and swap Edit with Run vrrr 2 1,509 11-09-2013, 04:04 PM
Last Post: vrrr
  HP Prime Programming Tutorial #1: LOCAL, RETURN Eddie W. Shore 6 2,976 10-26-2013, 08:42 PM
Last Post: Miguel Toro
  WP-34S return to HP-30B Mike Wilson 14 3,506 09-13-2012, 10:19 PM
Last Post: Tim Wessman
  Return of the HP 50g RS-232 serial cables Eric Rechlin 3 1,495 03-09-2012, 06:16 PM
Last Post: Andres Capdevila
  After Cuts, HP Labs Vows Return to Glory Days Kerem Kapkin (Silicon Valley, CA) 1 1,068 02-15-2012, 09:47 PM
Last Post: Howard Owen
  Return of the 15C with Bad Zebra? aj04062 3 1,449 12-23-2011, 01:52 PM
Last Post: uhmgawa
  Humbly, I return to the Gods: HP12c Help! CaribbeanHP12c 12 3,018 04-23-2008, 09:46 AM
Last Post: CaribbeanHP12c
  Money Weighted Return with HP 12C David Bag 3 1,357 02-04-2008, 09:04 AM
Last Post: David Bag
  should I return the HP35S from Walmart and wait for one from Samson Cables? andrewj 5 1,514 08-08-2007, 11:50 AM
Last Post: Ren
  HP 17bii+: Financial Management Rate of Return (FMRR) Question E 7 2,058 09-01-2006, 05:47 PM
Last Post: e

Forum Jump: