473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

How to read .dcm file using byte array

hi all

I m trying to read an .dcm file using byte array.But i dont know actually how to read byte code from file.please give me any example of reading byte code.
I search in google also...but in vein.
It's urgent...

please help.
Jun 28 '07 #1
3 4759
weaknessforcats
9,208 Expert Mod 8TB
C or C++?

If C++ use ifstream::get().

If C use fscanf().
Jun 28 '07 #2
It is DCOM image format..
I m new in DICOM
Expand|Select|Wrap|Line Numbers
  1.                     FILE *fp1;
  2.        char *c, *d;
  3.        c  = new char[8];
  4.        d = c;
  5.                    fp1=fopen("C:\\xyz.dcm","r");
  6.         ZeroMemory(c , 8);
  7.        for(int i=128;i<=132;i++)
  8.         {
  9.           fseek(fp1,i,SEEK_SET);
  10.  
  11.         *d =(char)fgetc(fp1);
  12.          d++;
  13.        }
  14.        CString s = c;
  15.  
  16.  
i m using this code.
Actually my file contains fillowing type of code

44 49 43 4d 02 00 00 00 - 55 4c 04 00 82 00 00 00

first 128 bytes are 0 and 44 is 129th byte

in hex format 44 49 43 4d is DICM called as tag..

55 4c is UL which is value type...

04 00 is value length which must be swaped as 00 04 tat is 4

& the next valu is of 4 bytes tat is 00 00 00 82 after swapping

I want to display tags and their values tat is

DICM & 82

How to travrese through this file where tag length is 4 bytes,Value type is of 2 bytes, value length is of 2 bytes, and value is no of bytes as value length.which is fixed...
Jun 29 '07 #3
It is DCOM image format..
I m new in DICOM
Expand|Select|Wrap|Line Numbers
  1.                     FILE *fp1;
  2.                     char *c, *d;
  3.                    c  = new char[8];
  4.                    d = c;
  5.                    fp1=fopen("C:\\xyz.dcm","r");
  6.                   ZeroMemory(c , 8);
  7.                   for(int i=128;i<=132;i++)
  8.                   {
  9.                    fseek(fp1,i,SEEK_SET);
  10.                   *d =(char)fgetc(fp1);
  11.                    d++;
  12.                  }
  13.                CString s = c;
  14.  
  15.  
i m using this code.
Actually my file contains fillowing type of code

44 49 43 4d 02 00 00 00 - 55 4c 04 00 82 00 00 00

first 128 bytes are 0 and 44 is 129th byte

in hex format 44 49 43 4d is DICM called as tag..

55 4c is UL which is value type...

04 00 is value length which must be swaped as 00 04 tat is 4

& the next valu is of 4 bytes tat is 00 00 00 82 after swapping

I want to display tags and their values tat is

DICM & 82

How to travrese through this file where tag length is 4 bytes,Value type is of 2 bytes, value length is of 2 bytes, and value is no of bytes as value length.which is fixed...

please give me some example if u have any to traverse DCOM file...
Jun 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Michael Van Altena via .NET 247 | last post by:
I'm trying to figure out how to read a formatted binary file intoa structure definition in C#. I've tried using the"StructLayout" attribute with both LayoutKind.Explicit andLayoutKind.Sequential...
5
by: AC [MVP MCMS] | last post by:
Any pointers on how to (1) read a Base64 encoded string from a text file and (2) write it to a binary file? I have a ton of files that are being generated from a legacy system. Each file...
3
by: Shaun Merrill | last post by:
Hey, here is my code. I am trying to read a file into a byte array. Please show me how this can work. Obviously I need to read into a dynamic array because it could read any file. So why does...
6
by: =?Utf-8?B?VGhvbWFzWg==?= | last post by:
Hi, Is it possible to read a file in reverse and only get the last 100 bytes in the file without reading the whole file from the begining? I have to get info from files that are in the last 100...
0
by: lovecarole | last post by:
hi, i am the student who should write a program about reading wav file and do the DFT. actually i don't know how to read data of the wav song and save it into the array... if i want to read...
14
by: chance | last post by:
Hello, I have a file on disk called TEMP.ZIP and I would like to somehow get this into a memory stream so I can eventually do this: row = dataStream.ToArray() However, I am not sure of the...
5
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
4
by: skunapareddy | last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the...
3
by: sam | last post by:
same as subject?
1
by: tom thomas | last post by:
Dear sir, i am very new to c# and i request you to... please look into the problem The following is the code(please see the code below:) which i uses to open the binary file,currently it works...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.