comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: read 12 bit array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: read 12 bit array [message #75585 is a reply to message #75569] Thu, 31 March 2011 08:00 Go to previous messageGo to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
On 31 mar, 15:52, Wox <s...@nomail.com> wrote:
> Hi all,
>
> Does anyone have an idea how to read a 12bit array from a file (not
> ASCII, just a binary dump).
>
> Thanks,
>
> Wout

Read it as [3,N] byte array b, if the file contains an array of 2*N 12
bits words.
Then transform the result to an integer (16 bits) array by b = fix(b,
0, 3, N)
Finally concatenate the first and last bytes of each triple with
corresponding half parts of the middle byte, that is :
[ b[0,*] or (ishft(b[1,*] and '0F'x,8), ishft(b[2,*],4) or
ishft((b[1,*] and 'F0'x), -4) ]
You should get your 12 bits array packed in a 16-bits array of same
size.
alx.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: hardware renderer
Next Topic: Bringing widgets to the front

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:26:44 PDT 2025

Total time taken to generate the page: 0.00438 seconds