473,651 Members | 2,437 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 4780
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
4599
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 options. I can get this to worksuccessfully, but only when I'm NOT dealing with arrays in thestructure definition. For example: In C, you are able to simply read a binary file intoa structure as follows: ...
5
4832
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 contains a (1) content type one one line, a (2) filename, and (3) the encoding type (seems to always be Base64, followed by the encoded string. A process will be to read the content type and filename, then create a new binary file and write out the...
3
12753
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 VB.NET give me the ability to read into a Byte Array if it doesn't allow me to use a variable sized array? Dim i As Short = FreeFile() FileSystem.FileOpen(i, Filename, OpenMode.Binary, OpenAccess.Read, OpenShare.Default) Dim iByteArray() As Byte
6
5795
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 bytes of the file and some of these files are 600Mb -1 GB in size. I am getting "outofMemory.." exceptions on the largest files and the other files take "forever" to get the last 100 bytes. This is the code I have currently that works with...
0
5777
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 17640 every times., and i set byte read=new byte, i have the wav format paper, but i don't know how to read the data correctly into the byte array, and used for doing DFT.... here's my code, and i am little hurry...thanks for the helps first~
14
11630
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 correct way to get it into a memory stream. Any help appreciated.
5
11253
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 couple areas that have ASCII text that I need to extract. At the end of the 2580 bytes, I can read the report like a standard text file. It should have CR/LF at the end of each line. What is the best way for me to read this report using C#. It is...
4
4241
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 code to read a blob from DB I am not having any luck, I am running this java programs using JDEVELOPER. Can anyone please give me some help? The code is as follows: ... private static byte getBytesFromBlob(Blob blob) throws Exception { ...
3
8903
by: sam | last post by:
same as subject?
1
8259
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 fine ,but now the problem is that 2 bytes are read in simultaneously and is being converted into an integer,but i need to read the data from the file in bits and finally convert 8 bits into binary numbers and then to decimal numbers? could you be...
0
8349
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8695
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7296
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6157
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5609
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4143
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.