Click here to Skip to main content
15,919,336 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Questions about reading binary files Pin
Mark Salsbery30-Sep-07 6:47
Mark Salsbery30-Sep-07 6:47 
GeneralRe: Questions about reading binary files Pin
GentooGuy30-Sep-07 6:55
GentooGuy30-Sep-07 6:55 
GeneralRe: Questions about reading binary files Pin
Mark Salsbery30-Sep-07 7:10
Mark Salsbery30-Sep-07 7:10 
GeneralRe: Questions about reading binary files Pin
GentooGuy30-Sep-07 14:51
GentooGuy30-Sep-07 14:51 
GeneralRe: Questions about reading binary files Pin
Mark Salsbery29-Sep-07 11:11
Mark Salsbery29-Sep-07 11:11 
GeneralRe: Questions about reading binary files Pin
Mark Salsbery29-Sep-07 11:22
Mark Salsbery29-Sep-07 11:22 
GeneralRe: Questions about reading binary files Pin
Luc Pattyn29-Sep-07 11:49
sitebuilderLuc Pattyn29-Sep-07 11:49 
AnswerRe: Questions about reading binary files Pin
Luc Pattyn30-Sep-07 4:31
sitebuilderLuc Pattyn30-Sep-07 4:31 
FYI:

I checked some JPEG documents and can confirm JPEG is "big-endian" which means multi-byte
quantities need their byte order reversed on a "little-endian" machine such as Intel's x86.

From the doc: "For parameters which are 2 bytes (16 bits) in length, the most significant
byte shall come first in the compressed data’s ordered sequence of bytes."

As already stated by Mark, this does NOT mean you should swap every pair of bytes; it does
mean if two bytes are to represent a 16-bit integer, then you should swap both bytes; if 4 bytes
represent a 32-bit integer, then you should swap all four bytes.

Since 2B and 4B integers will not always be properly aligned in memory, you will need
a method that interprets 2 bytes in the right order, whereever they are, as in the following
C# code snippet:

// unsigned !
private byte getByte() {
    return bytes[p++];
}

// unsigned and big-endian !
private ushort getShort() {
    ushort bHi=getByte();
    ushort bLo=getByte();
    return (ushort)((bHi<<8)+bLo);
}

where bytes[] holds the entire file content, and p is the "current position".

Smile | :)



Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


QuestionC++ Byte Level Code.. [modified] Pin
spalanivel27-Sep-07 21:26
spalanivel27-Sep-07 21:26 
AnswerRe: C++ Byte Level Code.. Pin
led mike28-Sep-07 5:19
led mike28-Sep-07 5:19 
GeneralRe: C++ Byte Level Code.. Pin
spalanivel2-Oct-07 5:24
spalanivel2-Oct-07 5:24 
QuestionSimple ESC Key Pin
Michael10127-Sep-07 18:18
Michael10127-Sep-07 18:18 
AnswerRe: Simple ESC Key Pin
Luc Pattyn28-Sep-07 7:44
sitebuilderLuc Pattyn28-Sep-07 7:44 
QuestionAnother DataGridView Question Pin
BuckBrown27-Sep-07 11:37
BuckBrown27-Sep-07 11:37 
AnswerRe: Another DataGridView Question Pin
BuckBrown27-Sep-07 11:49
BuckBrown27-Sep-07 11:49 
GeneralRe: Another DataGridView Question Pin
Luc Pattyn27-Sep-07 13:19
sitebuilderLuc Pattyn27-Sep-07 13:19 
GeneralRe: Another DataGridView Question Pin
BuckBrown28-Sep-07 6:02
BuckBrown28-Sep-07 6:02 
GeneralRe: Another DataGridView Question Pin
George L. Jackson28-Sep-07 10:23
George L. Jackson28-Sep-07 10:23 
GeneralRe: Another DataGridView Question Pin
BuckBrown28-Sep-07 10:34
BuckBrown28-Sep-07 10:34 
QuestionHow do you call a Parent Function from Child Form Pin
BuckBrown27-Sep-07 5:42
BuckBrown27-Sep-07 5:42 
AnswerRe: How do you call a Parent Function from Child Form Pin
BuckBrown27-Sep-07 11:33
BuckBrown27-Sep-07 11:33 
GeneralRe: How do you call a Parent Function from Child Form Pin
Rocky#27-Sep-07 18:18
Rocky#27-Sep-07 18:18 
GeneralRe: How do you call a Parent Function from Child Form Pin
BuckBrown28-Sep-07 7:21
BuckBrown28-Sep-07 7:21 
QuestionConverting double, float, byte, short, string int values to void* Pin
dreamz648027-Sep-07 3:19
dreamz648027-Sep-07 3:19 
AnswerRe: Converting double, float, byte, short, string int values to void* Pin
led mike27-Sep-07 4:41
led mike27-Sep-07 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.