The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP Prime - GETPIX_P Return?
Message #1 Posted by Thomas Chrapkiewicz on 24 Nov 2013, 7:39 a.m.

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?
Message #2 Posted by Patrice on 24 Nov 2013, 7:54 a.m.,
in response to message #1 by Thomas Chrapkiewicz

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?
Message #3 Posted by Thomas Chrapkiewicz on 24 Nov 2013, 10:36 a.m.,
in response to message #2 by Patrice

Thank you Patrice! Very nice code!

TomC

            
Re: HP Prime - GETPIX_P Return?
Message #4 Posted by Thomas Chrapkiewicz on 24 Nov 2013, 11:25 a.m.,
in response to message #2 by Patrice

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?
Message #5 Posted by Damien on 24 Nov 2013, 5:29 p.m.,
in response to message #4 by Thomas Chrapkiewicz

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?
Message #6 Posted by Thomas Chrapkiewicz on 25 Nov 2013, 9:12 a.m.,
in response to message #5 by Damien

Damien:

Thanks!

TomC

      
Re: HP Prime - GETPIX_P Return?
Message #7 Posted by cyrille de Brébisson on 25 Nov 2013, 1:58 a.m.,
in response to message #1 by Thomas Chrapkiewicz

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?
Message #8 Posted by Thomas Chrapkiewicz on 25 Nov 2013, 8:54 a.m.,
in response to message #7 by cyrille de Brébisson

Cyrille:

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

Regards,

TomC


[ Return to Index | Top of Index ]

Go back to the main exhibit hall