Saturday 15 September 2012

c# - crop image without copying -


I am writing an application for which I need to split a large image into smaller tiles, where each tile Essentially there is a crop version of the original image

Currently my partitioned operation looks something like this

  Tile Image = new bitmap image (); Tile.Image.BeginInit (); Tile Image.urisource = the main way Urios; Tile Image. Sources = new int 32wright (x * tile wide + x, y * tile height, tile wide, tile height); Tile.Image.EndInit (); Intuitively, I thought it would originally create a "reference" for the original image, and would only appear as a sub rectangle of the image. However, the slow speed at which I have different operations, I have been inspired to believe that it is actually copying the original image source reset, which is very slow for large images (a civilization 3-4 seconds of size while splitting is a size image).  

I looked a bit, but without duplicating any data, there was no way to attract a bitmap as a sub-rake of a large image. Any suggestions?

Use the system. Windows.Media.imaging.CroppedBitmap class:

  // Create a Croppy Bitmap from the original image Int32Rect rect = New Int32Rect (x * tileWidth + x, y * tileHyight, tileWidth, tileHeight); Cropped bitmap paused bitmap = new cropped bitmap (original image, text); // Create an image element image tile image = new image (); Tile image With = tile wide; Tile image Hect = tile heights; Tile image. Source = crop bitmap;    

No comments:

Post a Comment