I use Visual Studio 2022 C# language. (newbie...). I'd like to split one image into two (divide to half). The first image in the split image is input to first picutrebox and then the other second image is also input to second picutrebox.
So I first try to one image that input to picturebox (not split yet). - is it completed
FileStream myFileStream = new FileStream(imagepath, FileMode.Open, FileAccess.Read);
MemoryStream myStream = new MemoryStream();
byte[] photo = new byte[myFileStream.Length];
myFileStream.Read(photo, 0, photo.Length);
myStream.Write(photo, 0, photo.Length);
drawingImage = new Bitmap(myStream); -> //no error
Then I try to split image that in a very simply way in my think is just divide by 2. I thought it would be okay to put the value divided by the size into the byte variable. I made some modifications. Like here :
byte[] photo = new byte[myFileStream.Length / 2]; -> //just divide by 2
myFileStream.Read(photo, 0, photo.Length); //-> I thought I could only read the length.
myStream.Write(photo, 0, photo.Length);
drawingImage = new Bitmap(myStream); -> //error -> System.ArgumentException:"Invalid parameter."
The end goal is to divide high-capacity images.
How can I fix it?