zimmer9
asked on
Using C# with VS2015 do you know how I can reconfigure the 2 images that appear horizontally to make them instead appear vertical and enlarge the images to the max?
I am developing a C# application and I create 2 check images as follows:
Currently using the code below, the images appear horizontally and are small.
Do you know how I could make them appear vertically (have the 1st image appear on the top half of the screen and the 2nd image appear on the bottom half
of the screen) and have them both take up the full half of the screen (enlarge the images)?
I have attached an example of the 2 check images that are displayed on the screen so that you can see their size and placement on the screen.
MemoryStream ms = new MemoryStream(bytesFrImg, 0, bytesFrImg.Length);
ms.Write(bytesFrImg, 0, bytesFrImg.Length);
System.Drawing.Image image = System.Drawing.Image.FromS tream(ms, true);
MemoryStream ms1 = new MemoryStream(bytesBkImg, 0, bytesBkImg.Length);
ms1.Write(bytesBkImg, 0, bytesBkImg.Length);
System.Drawing.Image image1 = System.Drawing.Image.FromS tream(ms1, true);
int width = image.Width + image1.Width;
int height = Math.Max(image.Height, image1.Height);
Bitmap img3 = new Bitmap(width, height);
Graphics g = Graphics.FromImage(img3);
g.Clear(Color.Black);
g.DrawImage(image, new Point(0, 0));
g.DrawImage(image1, new Point(image.Width, 0));
g.Dispose();
image.Dispose();
image1.Dispose();
img3.Save("L:\\FINSYS\\FSM ain\\C\\S\ \B1.tiff", System.Drawing.Imaging.Ima geFormat.T iff);
img3.Dispose();
checkimageoutput.jpg
Currently using the code below, the images appear horizontally and are small.
Do you know how I could make them appear vertically (have the 1st image appear on the top half of the screen and the 2nd image appear on the bottom half
of the screen) and have them both take up the full half of the screen (enlarge the images)?
I have attached an example of the 2 check images that are displayed on the screen so that you can see their size and placement on the screen.
MemoryStream ms = new MemoryStream(bytesFrImg, 0, bytesFrImg.Length);
ms.Write(bytesFrImg, 0, bytesFrImg.Length);
System.Drawing.Image image = System.Drawing.Image.FromS
MemoryStream ms1 = new MemoryStream(bytesBkImg, 0, bytesBkImg.Length);
ms1.Write(bytesBkImg, 0, bytesBkImg.Length);
System.Drawing.Image image1 = System.Drawing.Image.FromS
int width = image.Width + image1.Width;
int height = Math.Max(image.Height, image1.Height);
Bitmap img3 = new Bitmap(width, height);
Graphics g = Graphics.FromImage(img3);
g.Clear(Color.Black);
g.DrawImage(image, new Point(0, 0));
g.DrawImage(image1, new Point(image.Width, 0));
g.Dispose();
image.Dispose();
image1.Dispose();
img3.Save("L:\\FINSYS\\FSM
img3.Dispose();
checkimageoutput.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My guess is that your images are originally wonky. I am posting the tif I created with my code. As you can see, I don't have that problem. Test your code with another set of images like the ones I used. I will include them.
These aren't even the same check or same size, but you can see it did okay.
CombinedTif.tif
Al_Barlick_Autographed_Cancelled_Che.jpg
Subcheck_BACK_shadow.gif
These aren't even the same check or same size, but you can see it did okay.
CombinedTif.tif
Al_Barlick_Autographed_Cancelled_Che.jpg
Subcheck_BACK_shadow.gif
ASKER
using (Graphics combinedGraphics = Graphics.FromImage(combine dBitmap))
{
combinedGraphics.Clear(Col or.Black);
combinedGraphics.DrawImage (image, 0, 0, image.Width, image.Height);
combinedGraphics.DrawImage (image1, 0, image.Height, image1.Width, image1.Height);
if (File.Exists(combinedTif))
{
File.Delete(combinedTif);
}
combinedBitmap.Save(combin edTif);
}
{
combinedGraphics.Clear(Col
combinedGraphics.DrawImage
combinedGraphics.DrawImage
if (File.Exists(combinedTif))
{
File.Delete(combinedTif);
}
combinedBitmap.Save(combin
}
ASKER
The bad news is that the front check image is taking up about 1/4 of the top of the screen and the back check image is taking up about 1/4 of the bottom half of the screen, which makes their contents hard to read. I have attached a display of the size and position of the 2 check images on the screen.
MemoryStream ms = new MemoryStream(bytesFrImg, 0, bytesFrImg.Length);
ms.Write(bytesFrImg, 0, bytesFrImg.Length);
System.Drawing.Image image = System.Drawing.Image.FromS
MemoryStream ms1 = new MemoryStream(bytesBkImg, 0, bytesBkImg.Length);
ms1.Write(bytesBkImg, 0, bytesBkImg.Length);
System.Drawing.Image image1 = System.Drawing.Image.FromS
string combinedTif = @"L:\\FINSYS\\FSMain\\C\\S
Bitmap combinedBitmap = new Bitmap(Math.Max(image.Widt
using (Graphics combinedGraphics = Graphics.FromImage(combine
{
combinedGraphics.Clear(Col
combinedGraphics.DrawImage
combinedGraphics.DrawImage
if (File.Exists(combinedTif))
{
File.Delete(combinedTif);
}
combinedBitmap.Save(combin
}
B.tiff