Topic Author
Posts: 7
Joined: 08 Mar 2020, 15:17

Crop an Image into 9 tiles

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".
        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();

            return BitmapSource.Create(width, height, 80, 80, rawImage, rawStride, BitmapSource.Format.BGR8);

User avatar
Site Admin
Posts: 3018
Joined: 20 Jan 2012, 17:18

Re: Crop an Image into 9 tiles

10 Mar 2020, 10:37

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
User avatar
Site Admin
Posts: 2061
Joined: 22 Dec 2011, 19:20

Re: Crop an Image into 9 tiles

10 Mar 2020, 16:24

Perharps you are looking for a solution like this: viewtopic.php?f=12&t=273

Who is online

Users browsing this forum: No registered users and 3 guests