Solved

Get image byte array

Posted on 2012-04-09
3
306 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: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:knowlton
ID: 37825631
Thanks!
0
 
LVL 5

Author Comment

by:knowlton
ID: 37825635
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now