473,503 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to read .dcm file using byte array

13 New Member
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 4764
weaknessforcats
9,208 Recognized Expert Moderator Expert
C or C++?

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

If C use fscanf().
Jun 28 '07 #2
Rupali12345
13 New Member
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
Rupali12345
13 New Member
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
4585
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
4816
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
12712
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
5778
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
5750
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
11616
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
11216
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
4209
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
8871
by: sam | last post by:
same as subject?
1
8233
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
7188
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
7313
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...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
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...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.