Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Efficient image processing

Efficient image processing

Scheduled Pinned Locked Moved C#
graphicswinformsquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jon Hulatt
    wrote on last edited by
    #1

    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;

    P 1 Reply Last reply
    0
    • J Jon Hulatt

      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;

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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.

      My blog | My articles

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups