[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Tiff conversion - little endian to big endian

David A. Coursey

12/3/2004 8:25:00 PM

I am writing a small app to convert Group4 tiffs to Group3. I also need them
to be big endian for my system to accept it properly. I have gotten
everything to work except for the byte order. I have searched every
newsgroup I could find and nobody seems to be converting from little to big
endian. I couldn't even find anything in system.drawing.imaging, unless I am
looking in the wrong place.

I would really appreciate some help on this.

thanks
dave
3 Answers

Franz Strele

12/10/2004 11:50:00 AM

0

hi,

maybe the "ColorMatrix" class (System.Drawing.Imaging-Namespace) can help
you there...

hth,
franz

"David A. Coursey" <DavidACoursey@discussions.microsoft.com> schrieb im
Newsbeitrag news:B208C830-4003-4770-B162-1FB3F22A21E1@microsoft.com...
>I am writing a small app to convert Group4 tiffs to Group3. I also need
>them
> to be big endian for my system to accept it properly. I have gotten
> everything to work except for the byte order. I have searched every
> newsgroup I could find and nobody seems to be converting from little to
> big
> endian. I couldn't even find anything in system.drawing.imaging, unless I
> am
> looking in the wrong place.
>
> I would really appreciate some help on this.
>
> thanks
> dave


Martin

12/14/2004 2:22:00 PM

0

dave,

this will convert a 16bit UNSIGNED int (ushort) from little to big
endian and vice versa:

return (ushort) ((( n & 0xFF00) >> 8) | ((n & 0x00FF) << 8));

where n is the unsigned short (uint16) to convert.

This is the code for 32 bit unsigned ints:

return ((( n & 0xFF000000) >> 24) |
(( n & 0x00FF0000) >> 8) |
(( n & 0x0000FF00) << 8) |
(( n & 0x000000FF) << 24));

again, it converts from little to big and vice versa. For signed
integers, you'll have to do a little extra to preserve the sign.

HTH,

Martin
--
POST BY: http://www... - Need .NET? Just ask, Please dotNET.us

Gerald Hernandez

12/17/2004 5:54:00 AM

0

There are any number of ways to deal with this.
From bit shifting, to pulling out the bytes and re-arranging them.
A long time ago while searching for a built-in way to do this in the
framework, I did finally find one. Due to the depth and vastness I knew it
must be in the somewhere, but it wasn't easy to find.
Check out System.Net.IPAddress
HostToNetworkOrder and NetworkToHostOrder

Although it is buried deep enough that I usually forget where I found it and
just use the old tried and true byte flipping method.

Gerald

"David A. Coursey" <DavidACoursey@discussions.microsoft.com> wrote in
message news:B208C830-4003-4770-B162-1FB3F22A21E1@microsoft.com...
> I am writing a small app to convert Group4 tiffs to Group3. I also need
them
> to be big endian for my system to accept it properly. I have gotten
> everything to work except for the byte order. I have searched every
> newsgroup I could find and nobody seems to be converting from little to
big
> endian. I couldn't even find anything in system.drawing.imaging, unless I
am
> looking in the wrong place.
>
> I would really appreciate some help on this.
>
> thanks
> dave