0

I'm new hire here,I've SQL database with bunch of tables. one specific table with 40-45 columns have a bitmap column with gigantic string(one single value in a cell). I have a scenario to convert this bitmap data and see what actually it contains (its not a valid image for sure). I browse many byte[]-array related articles available online but so far no help. Is there any way I can do this problem with WinForm or Console App as I don't have the complete or any part of the solution/project. I just have sql database.

     public byte[] imageToByteArray(System.Drawing.Image imageIn)
      {
         MemoryStream ms = new MemoryStream();
         imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
         return ms.ToArray();
      }

      public Image byteArrayToImage(byte[] byteArrayIn)
      {
          MemoryStream ms = new MemoryStream(byteArrayIn);
          Image returnImage = Image.FromStream(ms);
          return returnImage;
         }

Also, It's a TIFF image document with a "Add Stamp" script/configuration,how to see this bitmap data? and how to interpret the stamp/functionality part from this?

Read all this and many other resources. Using .NET, how can you find the mime type of a file based on the file signature not the extension

http://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images

Community
  • 1
  • 1
MAK
  • 29
  • 9

1 Answers1

0

You haven't posted an example data string, but this code might help. You could implement this in a C# console app for speed:

byte[] byteArr = System.IO.File.ReadAllBytes("image.tif");
System.IO.File.WriteAllBytes("image.tif", byteArr);

Assume you have already imported the data string into byteArr.

benstopics
  • 114
  • 6
  • benstopics Thank you for helping me out, Here's how I am reading data from db column(see code) where/how to create image.tif file or where is it coming from? byte[] img = (byte[])(reader[3]); – MAK Dec 30 '15 at 22:10
  • Also keep getting parameter not valid exception MemoryStream ms = new MemoryStream(img); picturebox1.Image = Image.FromStream(ms); – MAK Dec 30 '15 at 22:14