SebastianR#32262
I want to crop very large images according to their colors in each corner. I know of the Transforms.AutoCrop which just needs a color as argument. The problem is I only know the color at runtime. Both approaches from Accessing Pixel Data need to load the bitmap, which is not possible due to the size of the image.
I came up with:
But this is an extra pipeline I need to use and it just feels wrong. Furthermore it may not even be possible to start this Pipeline, because the reader is already used in another one which is under construction (the one which uses the autocrop).
Are there any other waysto access a pixels data without loading the entire bitmap?
I came up with:
- Cropping the image to the pixel I want the color of with a pipeline
- Load the bitmap.
- Use GetPixel(0,0)
var memoryStream = new MemoryStream();
using (var imageReader = ImageReader.Create(@"..\Input\largeImage.tif"))
using (var crop = new Crop(0, 0, 1, 1))
using (var writer = new TiffWriter(memoryStream))
{
Pipeline.Run(imageReader + crop + writer);
}
var resultReader = ImageReader.Create(memoryStream);
var color = resultReader.Frames[0].GetBitmap().GetPixel(0, 0);
But this is an extra pipeline I need to use and it just feels wrong. Furthermore it may not even be possible to start this Pipeline, because the reader is already used in another one which is under construction (the one which uses the autocrop).
Are there any other waysto access a pixels data without loading the entire bitmap?