Crop an Image into 9 tiles
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);
}
Re: Crop an Image into 9 tiles
ImageSource and all descendant classes like BitmapSource do not store the bits in CPU mem, the image is internally stored in a GPU texture. Reading back from the GPU is very slow and we don't provide that functionality. You need to implement this yourself at a higher level
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Crop an Image into 9 tiles
Perharps you are looking for a solution like this: viewtopic.php?f=12&t=273
Who is online
Users browsing this forum: Bing [Bot] and 6 guests