Efficient image processing
-
I have to chop up some seriously large TIFF files into small tiles in png format. The source files are approxx 8000x8000 pixels, and the output tiles will be about 100x100 pixels. I've written code to do this with GDI+ :- open the source image, and loop through creating target images, and getting Graphics.FromImage etc to draw them. but it's very very very slow. I've tried multithreading to use my multiple cores, but the threads don't seem to schedule simultaneously - seems that something in GDI+ is stopping that working. Anyone know of any suitable image processing componenets that can do this task more effiecently? Thanks Jon
using System.Beer;
-
I have to chop up some seriously large TIFF files into small tiles in png format. The source files are approxx 8000x8000 pixels, and the output tiles will be about 100x100 pixels. I've written code to do this with GDI+ :- open the source image, and loop through creating target images, and getting Graphics.FromImage etc to draw them. but it's very very very slow. I've tried multithreading to use my multiple cores, but the threads don't seem to schedule simultaneously - seems that something in GDI+ is stopping that working. Anyone know of any suitable image processing componenets that can do this task more effiecently? Thanks Jon
using System.Beer;
Have you tried scanning through your source image using an unsafe region?
public static bool Extract(Bitmap b)
{
BitmapData bmData = b.LockBits(new Rectangle(0,0, b.Width, b.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
IntPtr scan0 = bmData.Scan0;
unsafe
{
byte *p = (byte*)(void*)scan0;
//... Extract the image here}
}The code you are using to extract your image portions would obviously go after the byte* p section.
Deja View - the feeling that you've seen this post before.