Avatar of zimmer9
zimmer9
Flag for United States of America asked on

Using C#, how would you convert var type variables to image type variables to pass to a function?

I am writing a C# console application that generates 2 files in binary format.

1 file is comprised of the front images of checks.

1 file is comprised of the back images of checks.

Do you know how I could modify this code (in particular the Function call) to merge these 2 TIFF files together into 1 TIFF file (called a multipage TIFF image)?

I want to give the user the ability to read the front image of a particular check image and then read the back image of the same check.

The img variable contains the front images of checks.
The img1 variable contains the back images of checks.
------------------

var img = bytes.Skip(irecpositionrevised + irectypelength).Take(intpos1revised).ToArray();

var img1 = bytes.Skip(irecpositionrevised + irectypelength + intpos1revised).Take(intpos2revised).ToArray();

MergeTwoImages(img, img1)  <--------  This will not work because the data type needs to be converted


public static Bitmap MergeTwoImages(Image firstImage, Image secondImage)
{
if (firstImage == null)
{
      throw new ArgumentNullException("firstImage");
}

if (secondImage == null)
{
      throw new ArgumentNullException("secondImage");
}

int outputImageWidth = firstImage.Width > secondImage.Width ? firstImage.Width : secondImage.Width;

int outputImageHeight = firstImage.Height + secondImage.Height + 1;

Bitmap outputImage = new Bitmap(outputImageWidth, outputImageHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

using (Graphics graphics = Graphics.FromImage(outputImage))
{
     graphics.DrawImage(firstImage, new Rectangle(new Point(), firstImage.Size),
               new Rectangle(new Point(), firstImage.Size), GraphicsUnit.Pixel);
     graphics.DrawImage(secondImage, new Rectangle(new Point(0, firstImage.Height + 1), secondImage.Size),    
               new Rectangle(new Point(), secondImage.Size), GraphicsUnit.Pixel);
}

return outputImage;
}
C#.NET Programming

Avatar of undefined
Last Comment
ste5an

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ioannis Paraskevopoulos

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes