Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Pack bitmap bytes into native-endian 32bit int

Reply
Thread Tools

Pack bitmap bytes into native-endian 32bit int

 
 
Ben Bacarisse
Guest
Posts: n/a
 
      01-16-2011
luser- -droog <(E-Mail Removed)> writes:

> Alright. I finally understood what Nobody was saying.
> I've reasoned through each line and it *should* work.
> But something's still not right!
>
> Since the operation of shifting should automatically
> follow the natural endianness, I should always read
> the bytes from most- to least-significance, right?


I can't answer this exactly since your code seems to have a very
different view of endianness to the conventional one. You seem to be
using the term to refer to bit order rather than byte order.

Shifting is defined to be like multiplying by a power of two the answer
seems to be "yes", but if the whole word need to be reversed (because
the bit-order needs to be changed) then reversing the bit in each byte
might not be enough.

> Then all that's necessary is to reverse the byte
> before masking IFF it's little-endian, right?


That's not a C question and I'm not a Cairo expert. All I can say is
that endianness does not usually refer to bit order but to byte order.
To know the correct transformation, one would need to know the byte and
bit order to Postscript bit masks and the same for the 32-bit Cairo bit
masks that you are building. I think a graphics group would get you
more informed audience.

<snip>
--
Ben.
 
Reply With Quote
 
 
 
 
luser- -droog
Guest
Posts: n/a
 
      01-17-2011
On Jan 16, 8:02*am, Ben Bacarisse <(E-Mail Removed)> wrote:
> luser- -droog <(E-Mail Removed)> writes:
> > Alright. I finally understood what Nobody was saying.
> > I've reasoned through each line and it *should* work.
> > But something's still not right!

>
> > Since the operation of shifting should automatically
> > follow the natural endianness, I should always read
> > the bytes from most- to least-significance, right?

>
> I can't answer this exactly since your code seems to have a very
> different view of endianness to the conventional one. *You seem to be
> using the term to refer to bit order rather than byte order.
>
> Shifting is defined to be like multiplying by a power of two the answer
> seems to be "yes", but if the whole word need to be reversed (because
> the bit-order needs to be changed) then reversing the bit in each byte
> might not be enough.
>
> > Then all that's necessary is to reverse the byte
> > before masking IFF it's little-endian, right?

>
> That's not a C question and I'm not a Cairo expert. *All I can say is
> that endianness does not usually refer to bit order but to byte order.
> To know the correct transformation, one would need to know the byte and
> bit order to Postscript bit masks and the same for the 32-bit Cairo bit
> masks that you are building. *I think a graphics group would get you
> more informed audience.
>
> <snip>
> --
> Ben.


Thanks. Hopefully, I've lurked on the Cairo list long enough to
hazard the question there.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! How can I draw a bitmap only with BITMAP information! xqggz C++ 1 06-19-2007 03:07 PM
An int that is 4 bytes in native, and 12 bytes in .NET? Huh? BogusException C++ 7 02-06-2007 04:47 AM
Masked bitmap from bitmap Gandalf Python 0 01-29-2004 09:41 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments