Solved

Get image byte array

Posted on 2012-04-09
3
324 Views
Last Modified: 2012-04-09
Given the path to the image:

pixtools_mod1.tif

Is it possible to get a reprentation of the .TIF as a byte array  (byte[ ]) ?

byte[] annotationImage;

annotationImage = foo.GetByteArray("pixtools_mod1.tif");


...something like that?

Please provide possible source code for the method GetByteArray(string pathToImage);


I will be looking for the answer as well.  :)


Thank you,

Tom
0
Comment
Question by:Tom Knowlton
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37825629
Try something like this:
            string FileName = "pixtools_mod1.tif";
            Image img = Image.FromFile(FileName);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            img.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
            img.Dispose();
            byte[] annotationImage = ms.ToArray();
            ms.Dispose();

Open in new window

0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 37825631
Thanks!
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 37825635
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Object Oriented Programming, C#, referencing, scoping. 13 83
vb.net winforms sizing/resolution? 4 54
Vb.net threads keep increasing 2 48
How to force output to ascii 2 31
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question