Solved

Get image byte array

Posted on 2012-04-09
3
297 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
Comment Utility
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
Comment Utility
Thanks!
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

11 Experts available now in Live!

Get 1:1 Help Now