Crop an Image into 9 tiles
Posted: 08 Mar 2020, 15:31
How can I divide an image into many other tiles ?
What I have at the moment is a "random image generator".
But what I would need is a way to read the bytes of a bitmap image in order to copy only some part of the image I guess.
But how can I access the bytes of a bitmap Image ?
Here is some code I use to create the "random image".
What I have at the moment is a "random image generator".
But what I would need is a way to read the bytes of a bitmap image in order to copy only some part of the image I guess.
But how can I access the bytes of a bitmap Image ?
Here is some code I use to create the "random image".
Code: Select all
private BitmapSource CreateImage(BitmapImage image)
{
// Define parameters used to create the BitmapSource.
int width = 200;
int height = 200;
int rawStride = (width * 8 + 7) / 8;
byte[] rawImage = new byte[rawStride * height];
// Initialize the image with data.
Random value = new Random();
value.NextBytes(rawImage);
return BitmapSource.Create(width, height, 80, 80, rawImage, rawStride, BitmapSource.Format.BGR8);
}